0

In my application i'm using solver.In this i created a Decision function that is working fine. But i want to use Decision function in Math.Exp function. For better understanding refer source code below,

using Microsoft.SolverFoundation.Services;
using Microsoft.SolverFoundation.Solvers;

SolverContext context = SolverContext.GetContext();
Model model = context.CreateModel();

Decision sv = new Decision(Domain.RealNonnegative, "decision");           
model.AddDecision(sv);  

model.AddConstraint("limits", 5 <= sv <= 20);

model.AddGoal("Result", GoalKind.Minimize, (1 - Math.Exp(sv));//here i'm getting exception

Please guide me how to use solver decision in Math.Exp function. This one required for my project requrement.

Tyress
  • 3,573
  • 2
  • 22
  • 45
shivcena
  • 2,023
  • 8
  • 24
  • 50
  • 1
    Can you tell us the details of the exception? Like Exception Type or Exception Message – Jens Meinecke Feb 18 '16 at 10:04
  • Basically in Math.Exp(double d) , the parameter should be double data type value , but i'm giving Decision type variable inside it, so that it is giving unhandled exception – shivcena Feb 18 '16 at 13:27
  • @shivcena please post the complete exception message, including its call stack. It's easy to do, just call Expression.ToString(). Neither the question nor the comments make much sense. – Panagiotis Kanavos Feb 19 '16 at 08:01
  • Also explain what you are trying to do. `Math.Exp` has nothing to do with Solver, it's just .NET's exponential function. Why would you want to pass an object as an argument to it and what would you expect as answer? – Panagiotis Kanavos Feb 19 '16 at 08:04

2 Answers2

0

As per the reference in google for Math.Exp() function we have to use double as a parameter.

shivcena
  • 2,023
  • 8
  • 24
  • 50
0

Try using: Model.Exp() instead of Math.Exp()