private void addResources() { //create a variable for each resource var firstTerm = true; Term resourceTerm = null; resources = new Dictionary <string, Decision>(); foreach (var op in AifFile.OperationTypes) { var decision = new Decision(Domain.IntegerNonnegative, op); ProblemModel.AddDecision(decision); resources[op] = decision; resourceTerm = firstTerm ? decision : resourceTerm + decision; firstTerm = false; } Log.Debug("Resource Types: " + string.Join(", ", AifFile.OperationTypes)); Log.Trace("Constraint (ResourceLowerBounds): " + ProblemModel.AddConstraints("ResourceLowerBounds", resources.Values .Select(decision => decision >= 1) .ToArray()).Expression); Log.Trace($"Resources Goal: {ProblemModel.AddGoal("resources", GoalKind.Minimize, resourceTerm).Expression}"); }
private void buildLinearModel() { addResources(); //add a constraint that ensures that an operation only starts once Log.Trace("Constraint (OperationsStartOnlyOnce): " + ProblemModel.AddConstraints("OperationsStartOnlyOnce", OperationCycleRanges .Select(op => op.CreateVariables()) .ToArray()).Expression); //add a constraint that ensures sequencing relations are satisfied Log.Trace("Constraint (SequencingRelations): " + ProblemModel.AddConstraints("SequencingRelations", OperationCycleRanges .SelectMany(op => op.GetSequencingTerms()) .ToArray()).Expression); //Resource bounds must be satisfied Log.Trace($"Constraint (ResourceBounds): {ProblemModel.AddConstraints("ResourceBounds", getResourceConstraints().ToArray()).Expression}"); }