3

Matlab's optimproblem class of objects allows users to define an Integer Linear Program (ILP) problems using symbolic variables. This is dubbed the "problem-based" formulation. Internal methods takes care of setting up the detailed ILP formulation by assembling the coefficient arrays and matrices for the objective function, equality constraints, and inequality constraints. In Matlab, these details are referred to as the "structure" for the "solver-based" formulation.

Users can see the order in which the optimproblem.Variables are taken in setting up the solver-based formulation by using prob2struct to explicitly convert an optimizationproblem object into a solver-based structure. The Algorithms section of the prob2struct page, the variables are taken in the order in which they appear in the optimizationproblem.Variables property.

I haven't been able to find what determines this order. Is there any way to control het order, maybe even change it if necessary? This would allow one to control the order of the scalar variables of the archetypal ILP problem setup, i.e., the solver-based formulation.

Thanks.

Reason for this question

I'm using Matlab as a prototyping environment, and may be relying on others to develop based on the prototype, possibly calling other solver engines. An uncontrolled ordering of variables makes it hard to compare, especially if the development has a deterministic way of arranging the variables. Hence my wish to control the variable ordering. If this is not possible, it would be nice to know. I would then know to turn my attention completely to mitigating the challenge of disparately ordered variables.

user36800
  • 2,019
  • 2
  • 19
  • 34
  • The order of variables (or equations) has no predictable influence on the solution time. I never care about the ordering. – Erwin Kalvelagen May 14 '19 at 05:38
  • Understood. I'm using Matlab as a prototyping environment, and may be relying on others to develop based on the prototype, possibly calling other solver engines. An uncontrolled ordering of variables makes it hard to compare, especially if the development has a deterministic way of arranging the variables. Hence my wish to control the variable ordering. – user36800 May 14 '19 at 10:59
  • Looks to me ordering is largely an irrelevant issue for that purpose. – Erwin Kalvelagen May 14 '19 at 12:11
  • Not sure why you would say that. – user36800 May 14 '19 at 13:56
  • I agree with Erwin. Across a wide range of solvers, problem types and model formulations, nobody in the past 50 or so years has been able to find any predictable influence on solving time based on the ordering of the variables. For the same reason, you should never rely on one or a small number of benchmark instances. I have found cases where different instances of the same basic problem will perform better on different solvers, sometimes by an order of magnitude or more. – TimChippingtonDerrick May 15 '19 at 05:53
  • When comparing results from different solvers/modeling tools, it is best to retrieve solution values by their name (opposed to some sequence number). All modern tools use names instead of variable number nnnn. Secondly, in many MIP models there are multiple optimal (or close) solutions. In that case you can only compare the optimal objective value. – Erwin Kalvelagen May 15 '19 at 09:00
  • Thanks for explaining, Tim & Erwin. I'm not saying that the order of the variables significantly affects the solution. The problem-based approach saves me from manually tracking which elements in which multidimensional `OptimizationVariable` object map to which elements in the solver-based formulation's column vector of ILP variables. I *assumed* that 3rd party solvers take arguments like [`intlinprog`'s](http://www.mathworks.com/help/optim/ug/intlinprog.html). There is no information about what the rows of the resulting column vector correspond to. So I need the mapping. – user36800 May 15 '19 at 15:38
  • Ideally, I would even dictate the mapping by specifying the order in which the `OptimizationVariable` objects are taken. As mentioned, this is determined by the order in which they appear in an `optimizationproblem` oject's `Variables` property, so it boils down to an *assured* away by which one can determine such an order, e.g., perhaps by the order in which the optimization expression or constraints are defined. – user36800 May 15 '19 at 15:38
  • If the 3rd party solvers also allow retrieval of results by variable name, it means that they also have a problem-based abstraction layer, similar to Matlab's, above the solver-based layer. In that case, the problem is transformed into one of how to call such an external problem-based flow from Matlab. I guess I will discover whether this is case as I proceed. – user36800 May 15 '19 at 15:39
  • I didn't quite follow the remark about only comparing objective values for multiple similar optima. I would imagine that one would be interested in the value of the decision and indicator variables, as one of those solutions would be implemented. – user36800 May 15 '19 at 15:40

0 Answers0