ISolution IModel.Solve(CancellationToken cancellation) { var rq = new Protocol.Request() { constraints = constraints.Select(ToProtocolExpr).ToArray(), goal = new Protocol.Request.Goal() { expr = ToProtocolExpr(minimize.Aggregate( (Expr)null, (agg, d) => agg != null ? (Expr) new OperatorExpr() { Op = OperatorExpr.OpType.Add, Left = agg, Right = new TermExpr() { Variable = d } } : new TermExpr() { Variable = d } )) } }; var rsp = owner.Solve(rq, cancellation); if (rsp.status == Protocol.Response.Solved && rsp.variables != null) { decisions.ForEach(d => rsp.variables.TryGetValue(d.id, out d.value)); } return(new Solution() { status = rsp.status }); }
protected abstract Protocol.Response Solve(Protocol.Request request, CancellationToken cancellation);