I have the following English question
There exists one school student.
And I would like to translate it to ALCQO or First order logic.
I have written the following:
∃SchoolStudent
or in First Order Logic:
∃x(SchoolStudent(x))
However, I know from mathematics and the theory that ∃ is translated as "at least one" or "some". Thus, I am wondering if the following two options are correct:
approach 1
¬∃x(SchoolStudent(x))
approach 2
(≥1student.SchoolStudent)⊓(≤1student.SchoolStudent)
∃SchoolStudent is meaningless in ALCQO. The only constructor available in ALCQO using existential restrictions are of the form
∃r.C
which is interpreted as
{d ∈ ΔI | there is an e ∈ ΔI with (d, e) ∈ rI and e ∈ CI}
In first order logic ∃r.C translates to πx(∃r.C) = ∃y.r(x, y) ∧ πy(C).
To define a school with only 1 student you will have to have the concepts School and Student and a role which can be used to associate a student with a school, say hasStudent.
School ≡ ∃hasStudent.Student ⊓ ≤1hasStudent.Student
This means School here is the set of schools that have only a single student.
But we can also define School as anything that has more than 1 student and then define a specific individual of the school as a school with only 1 student.
School ≡ ∃hasStudent.Student
School(x)
≤1hasStudent.Student(x)
Example:
Students want to enroll in multiple courses of different course groups (Math, English, Spanish, History) and have issued preferences for each course group (ENG-1 > ENG-2 means course ENG-1 is preferred to course ENG-2).
Student A:
MATH-2 > MATH-4 > MATH-1 > ... > MATH-9
ENG-3 > ENG-4 > ENG-1 > ... > ENG-2
Student B:
ENG-1 > ENG-2 > ENG-4 > ... > ENG-3
SPA-4 > SPA-6 > SPA-3 > ... > SPA-2
HIST-1 > HIST-3 > HIST-2 ... > HIST-5
Student C:
...
Is it possible for a planning variable of each student (planning entity) to be a combination of each of their preferences? I.e. student A would be assigned MATH-2 and ENG-3, student B would be assigned ENG-1, SPA-4, and HIST-1, if the constraints allow for this.
Yes (and no). Technically no, because #PlanningVariable can only hold a single value.
But YES, OptaPlanner can handle your use case. You just need to choose the right way to map your domain to Java classes. You need to model a N:M relation between Student and Course:
Student A needs to enroll in 2 courses (one from the MATH group and one from the ENG group).
Student B needs to enroll in 3 courses (ENG, SPA, HIST).
etc.
You can model this type of relationship with the CourseAssignment class, which is your #PlanningEntity. It could look like this:
#PlanningEntity
class CourseAssignment {
final Student student; // e.g. Ann
final CourseGroup courseGroup; // e.g. MATH
#PlanningVariable(valueRangeProviderRefs = { "courseRange" })
Course course; // changed by Solver - could be MATH-1, MATH-2, ENG-1, HIST-...
}
Since the number of course assignments is known for each student and it's fixed, you'd simply create 2 CourseAssignment instances for Student A, 3 instances for Student B, etc.
Next, design your constraints to penalize each courseAssignment with a hard score penalty, if courseAssignment.course.group != courseAssignment.courseGroup and with a soft score penalty based on courseAssignment.student.getPreference(courseAssignment.course).
I want to query the "instance of P31" and "health specialty P115" for a disease name
"left bundle branch hemiblock (Q2143688)"
I want an output like :
left bundle branch hemiblock (Q2143688)
instance of : thoracic disease
health specialty :cardiology
Also is it possible to query all disease information with its instance of and health specialty, so that I can store it and process each time I need an information.
Hi Guys i have a complex object as below and would like to know how to write mapper.xml for the same.
I have knowledge to insert a simple object, but i am not getting this with 2 levels of Hierarchy.
Below is my domain object
class Org{
id=O1
str1;
List<Division>
}
class Divison{
id = D1
org = O1
str2;
List<Employees>
List<Managers>
}
class Employees{
str3;
id = E1
divId = D1
}
class Managers{
str3;
id = M1
divId = D1
}
So Org has multiple Divisons, Each Divison has multiple Employees and Managers.
How can i write my mybatis mapper.xml so that i can insert Organization, Divison, Employees and Managers to respective tables in one transaction
Sorry for the vague question topic!
I've got a particular relational-algebra problem that has me and a couple of friends stumped.
Now, here's the question:
For each department, find the maximum salary of instructors in that
department. You may assume that every department has at least one
instructor.
I'll upload the schema as well, as a visual aide.
I've worked this out to a point;
I need a relation that includes all the instructors in any department, we've got that. It's the instructor relation.
Out of that relation i need to 'split' it up into a per-department basis. and once I have that relation I just take the max(salary) and return that.
Problem is, the only way I can think of to do that is something like this:
π(max(salary)(σ(dept_name = x(instructor)))
Where x = whatever dept_name i'm looking for, but If I did it this way, then I'd have to do a new relation for every department!
How would you do it?
(Note: I just copy and paste'd the symbols from wikipedia if you want to use them in your answer)
My relational algebra might be a bit rusty but I think that
dept_name_G_{max(salary)}(
σ_{ddept_name = idept_name}(
ρ_{dept_name/ddept_name}(department) ⨯
ρ_{dept_name/idept_name}(instructor)
)
)
is what you seek for.
Remember that all projections are just operations on sets. The first thing you would do to
connect the information of department and instructor is to bring the information together.
So you want to join department and instructor, basically a cross product (⨯):
department = {(depA, 100$), (depB, 200$)}
instructor = {(will, depA, 10$), (bob, depB, 20$), (will, depB, 9$)}
department ⨯ instructor = {
(depA, 100$, will, depA, 10$),
(depA, 100$, bob, depB, 20$),
...,
(depB, 200$, will, depA, 10$),
...
}
So what you would want now is to filter the tuples where the dept_name of the instructor equals the
dept_name of the department. But you also notice that you now have a naming collision,
namely the column dept_name comes up twice.
As you can't simply do σ_{dept_name = dept_name}(department ⨯ instructor) you need to rename at
least one of the dept_name fields. I renamed both for clarity which one belongs to what.
So what you now have is
σ_{ddept_name = idept_name}(
ρ_{dept_name/ddept_name}(department) ⨯
ρ_{dept_name/idept_name}(instructor)
)
giving you:
{
(depA, 100$, will, depA, 10$),
(depB, 200$, bob, depB, 20$),
(depB, 200$, will, depB, 9$)
}
The whole process is a natural join and can be expressed shortly with:
department ⋈ instructor
Now the final step is to project the maximum salary per department. A simple projection can't do that
but the aggregation operator can:
{dept_name}_G_{max(salary)}(department ⋈ instructor)
results in
{
(depA, 10$),
(depB, 20$)
}