use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.
the class ProblemFactChangeUtil method unlinkTaskAssignment.
/**
* Unlinks a task assignment from the elements chain and relinks the remaining part of the chain to the specified
* previous chain element.
*
* @param taskAssignment a task assigning element to unlink from the chain.
* @param previousElement a ChainElement to relink the chain remainder to.
*/
public static void unlinkTaskAssignment(TaskAssignment taskAssignment, ChainElement previousElement, ScoreDirector<TaskAssigningSolution> scoreDirector) {
TaskAssignment nextTaskAssignment = taskAssignment.getNextElement();
if (nextTaskAssignment != null) {
scoreDirector.beforeVariableChanged(nextTaskAssignment, PREVIOUS_ELEMENT);
nextTaskAssignment.setPreviousElement(previousElement);
scoreDirector.afterVariableChanged(nextTaskAssignment, PREVIOUS_ELEMENT);
}
}
use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.
the class ReleaseTaskProblemFactChange method doChange.
@Override
public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) {
TaskAssignment workingTaskAssignment = scoreDirector.lookUpWorkingObjectOrReturnNull(taskAssignment);
if (workingTaskAssignment == null || workingTaskAssignment.getPreviousElement() == null) {
// or it's simply not yet assigned.
return;
}
// unlink the workingTaskAssignment from the chain.
ChainElement previousElement = workingTaskAssignment.getPreviousElement();
unlinkTaskAssignment(workingTaskAssignment, previousElement, scoreDirector);
scoreDirector.beforeVariableChanged(workingTaskAssignment, PREVIOUS_ELEMENT);
workingTaskAssignment.setPreviousElement(null);
scoreDirector.afterVariableChanged(workingTaskAssignment, PREVIOUS_ELEMENT);
if (workingTaskAssignment.isPinned()) {
scoreDirector.beforeProblemPropertyChanged(workingTaskAssignment);
workingTaskAssignment.setPinned(false);
scoreDirector.afterProblemPropertyChanged(workingTaskAssignment);
}
scoreDirector.triggerVariableListeners();
}
use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.
the class RemoveTaskProblemFactChange method doChange.
@Override
public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) {
TaskAssigningSolution solution = scoreDirector.getWorkingSolution();
TaskAssignment workingTaskAssignment = scoreDirector.lookUpWorkingObjectOrReturnNull(taskAssignment);
if (workingTaskAssignment != null) {
ChainElement previousElement = workingTaskAssignment.getPreviousElement();
unlinkTaskAssignment(workingTaskAssignment, previousElement, scoreDirector);
scoreDirector.beforeEntityRemoved(workingTaskAssignment);
// Planning entity lists are already cloned by the SolutionCloner, no need to clone.
solution.getTaskAssignmentList().remove(workingTaskAssignment);
scoreDirector.afterEntityRemoved(workingTaskAssignment);
scoreDirector.triggerVariableListeners();
}
}
use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.
the class AbstractTaskAssigningCoreTest method printSolution.
public static void printSolution(TaskAssigningSolution solution, StringBuilder builder) {
solution.getUserList().forEach(user -> {
appendln(builder, "------------------------------------------");
appendln(builder, printUser(user));
appendln(builder, "------------------------------------------");
appendln(builder);
TaskAssignment taskAssignment = user.getNextElement();
while (taskAssignment != null) {
builder.append(" -> ");
appendln(builder, printTask(taskAssignment));
taskAssignment = taskAssignment.getNextElement();
if (taskAssignment != null) {
appendln(builder);
}
}
appendln(builder);
});
}
use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.
the class TaskAssigningGenerator method createTaskAssigningSolution.
private TaskAssigningSolution createTaskAssigningSolution(String fileName, int taskListSize, int groupListSize, int userListSize) {
List<Group> groupList = createGroupList(groupListSize);
List<User> userList = createUserList(userListSize, groupList);
List<TaskAssignment> taskAssignmentList = createTaskAssignmentList(taskListSize, userList, groupList);
TaskAssigningSolution solution = new TaskAssigningSolution("0", userList, taskAssignmentList);
BigInteger totalFacts = AbstractSolutionImporter.factorial(taskListSize + userListSize - 1);
BigInteger fixedFacts = AbstractSolutionImporter.factorial(userListSize - 1);
BigInteger possibleSolutionSize = (totalFacts == null || fixedFacts == null) ? null : totalFacts.divide(fixedFacts);
LOGGER.info("TaskAssigningSolution {} has {} tasks, {} groups, and {} users with a search space of {}.", fileName, taskListSize, groupListSize, userListSize, AbstractSolutionImporter.getFlooredPossibleSolutionSize(possibleSolutionSize));
return solution;
}
Aggregations