On working with ranges of real numbers in Microsoft Solver Foundation

Unanswered On working with ranges of real numbers in Microsoft Solver Foundation

  • Thursday, April 26, 2012 4:21 PM
     
      Has Code

    Hi,

    I'm working on  project utilising Microsoft Solver Foundation and am having some difficulty coming up with an appropriate configuration for the solver (via the properties of its directive).

    As an example I have a model comprising one parameter "output" bound to a single value and two decisions "inputA" & "inputB" whose domain is over a range of real numbers - in this case 0 to 5...

    A constraint is made representing a simple equality equation: output == inputA / inputB

    If for example I run the solver and deliberately set the value of the parameter to an infeasible value such as -2.5 (since the decisions domain falls between 0 to 5) the solver will run continuously - to the point where a colleague of mine left the example running on his office pc overnight and came back the next morning and it was still running...

    The project requires the use of real numbers hence I can't simply change the domain range type, and the value represented by the "output" parameter is generated externally.

    This issue appears to only happen when the equation represented in the constraint is either a division or multiplication - Setting the PresolveLevel value seems to have little impact on the above example?

    Any suggestions or guidance would be greatly appreciated.

    I have posted a related question at http://stackoverflow.com/questions/10315437/on-working-with-ranges-of-real-numbers-in-microsoft-solver-foundation

    ...and here is the code example:

    	private static void Main(string[] args)
            {   
                const double DESIRED_OUTPUT_VALUE = -2.5;
    
                SolverContext solver = SolverContext.GetContext();
                Model model = solver.CreateModel();
                
                //Defined a value to be tested against                  
                Parameter output = new Parameter(Domain.Real, "output");
                output.SetBinding(DESIRED_OUTPUT_VALUE);
    
                //Defined a range between 1 & 10 for the input variables.
                Domain inputDomain = Domain.RealRange(0, 5);
                Decision inputA = new Decision(inputDomain, "inputA");
                Decision inputB = new Decision(inputDomain, "inputB");
                
                model.AddDecision(inputA);
                model.AddDecision(inputB);
                model.AddParameter(output);
                
                //The constraint, which is infeasible given the domain range and the value of paramter "output"
                 Constraint constraint = model.AddConstraint("result", output == inputA / inputB);
    
                /*Expected that the solver would report back quickly that this is no feasable solution.
                 *However instead it just sits there with a blank screen... trying the hls directive
                 *with presolve, equaulitytolerance and arithmetic properties in various configurations
                 *has no noticable effect.
                 */
                HybridLocalSearchDirective directive = new HybridLocalSearchDirective();
                directive.PresolveLevel = 1;
                //directive.EqualityTolerance = 0.25;
                //directive.TimeLimit = 1500;
                
                Solution solution = solver.Solve();
                Report report = solution.GetReport();
                Console.WriteLine(report);
                Console.ReadLine();
               
            }

All Replies

  • Friday, April 27, 2012 6:34 AM
     
     

    Your best bet is to change the constraint so that you are not multiplying or dividing decision variables.  In this case, output * inputB == inputA.

    This will return Infeasible instantaneously.

    In general, linear constraints will be passed to LP solvers which are extremely robust and well tested.  As soon as there is a non-linear constraint then the non-linear solvers are invoked.  These are much less robust.


    Dr Michael F

  • Monday, April 30, 2012 8:09 AM
     
     
    Thanks for the reply,  I was afraid that might be the case.
  • Tuesday, June 26, 2012 8:48 PM
     
     

    Hi David,

    I am also facing the same issue with real numbers ranging between -4 to +4. Please let me know if you found the solution to resolve this problem.

    Any help would be highly appreciated. Thanks in Advance.

    ---------------------------------------

    Bhaskar