Job Application Problem

13 views
Skip to first unread message

Carlo Baumann

unread,
Jul 6, 2021, 5:37:38 PM7/6/21
to OptaPlanner development
Hi at all

My problem to solve is the following. I have employees and jobs. A job is of a specific profile (Dev, Manager, etc). Same for the employees. An employee can applicate on jobs. On every job application the employee can give a priority. Same on the job side.

These are the constraints:

Hard 1: An employee can only be assigned to one job
Hard 2: A job can only be assigned to one employee
Hard 3: The profile of the employee must match the profile of the job
Soft 1: The job with the highest priority is assigned (highest priority = 2*prio_emp + prio_job)

I'm struggling now on the hard constraint 3

// An employee and a job must have the same profile
private fun profileConstraint(constraintFactory: ConstraintFactory): Constraint {
return constraintFactory.from(Employee::class.java)
.join(Job::class.java, Joiners.equal(Employee::profile, Job::profile))
.penalize("profile constraint", HardSoftScore.ONE_HARD)
}

I also tried with filter.

In the solution are employees with the wrong job profile.
What is wrong on this constraint?

Thanks for your help.
Carlo

Carlo Baumann

unread,
Jul 6, 2021, 5:41:42 PM7/6/21
to OptaPlanner development

Radovan Synek

unread,
Jul 7, 2021, 6:37:35 AM7/7/21
to optapla...@googlegroups.com
Hi Carlo,

the "profileConstraint" does the exact opposite of what it's supposed to do by your description: it penalizes the solution for every pair of Employee and Job with a matching profile.

Instead, you might want to ".filter()" only the employees that are assigned to a job with a different profile. Something like:

.from(Employee.class)
.filter(employee -> !employee.profile.equals(employee.job.profile))
.penalize("profile constraint", HardSoftScore.ONE_HARD)

Hope that helps,
Radek

--
You received this message because you are subscribed to the Google Groups "OptaPlanner development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to optaplanner-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/optaplanner-dev/63f34818-6b13-4262-bcce-b4a55e254718n%40googlegroups.com.


--

Radovan Synek

Principal Software Engineer, Business Automation

Red Hat EMEA

Brno, Czech Republic

Reply all
Reply to author
Forward
0 new messages