CW1-无代写
时间:2023-03-17
Advanced Programming Paradigms
(6008CEM) — Assignment Brief
CW1: Portfolio of solutions to programming exercises
Dr Kamal Bentahar
2023
Advanced Programming Paradigms (6008CEM) — Assignment Brief 2023
Assignment Brief
Module Title: Advanced Programming Paradigms
Module Code: 6008CEM
Module Leader: Dr Kamal Bentahar
Cohort: 2022/23 JanMay
Coursework Title: CW1: Portfolio of solutions to programming exercises
Coursework type: Portfolio
To be completed as: Individual
Credit value assessed: 10 credits
Hand out date: 21/2/2023
Submission arrangement online: Aula. Submit URL to the CU GitHub repository of the portfolio.
(Do NOT commit to the repository after the deadline.)
File types andmethod of recording: Code files with comments. (CU GitHub repository.)
Due date and time: Monday 3/4/2023 at 6:00pm (UK Time)
Mark and Feedback date: We aim for a 2 week turnaround: 17/4/2023
Mark and Feedbackmethod: Electronic via CU GitHub/Aula
Estimated Time (hrs): 20 hours
The module as a whole is expected to take 200 hours of time. This includes not only the assess‑
ment but the lecture videos, the lab sessions, the work on formative assessment tasks and revi‑
sion for the final test. It is expected that the portfolio tasks themselves could be completed in
15‑20 hours. But that is on the assumption that students are up to date with the material and
have attempted the formative tasks. Otherwise they would take much longer.
Word Limit: 200 words for the Haskell task benchmarking. (See task’s description.)
200 words for the Prolog task testing. (See task’s description.)
N/A for code. (Codemust match the required specifications and should be commented.)
Module Learning Outcomes Assessed:
• (2) Solve programming problems with a functional programming language.
• (3) Use propositional and predicate logic statement to answer queries with a logic program‑
ming language.
• (6) Use a SAT/SMT‑solver to solve programming problems.
Submission Instructions
The portfolio tasks are in three parts. See the next pages for their full descriptions.
You will version control your work and host it under https://github.coventry.ac.uk/6008CEM‑2023
You only need to submit your repository’s URL on the Aula submission page.
Dr Kamal Bentahar 1
Advanced Programming Paradigms (6008CEM) — Assignment Brief 2023
Marking Scheme
You will be given a mark out of 100, according to the following mark‑scheme.
Themarks distribution is as follows:
Component Marks
Task 1 (Haskell) 40
Task 2 (Prolog) 30
Task 3 (Z3) 30
Detailed breakdown marking scheme for the three tasks is given with the tasks descriptions later in
this document.
Each topic will be marked on partial credit.
The phrase “Effective use of GitHub”, in the detailed marking guidance, refers to using GitHub as
a tool for software Version Control, as opposed to simple “cloud storage”. Effectiveness is assessed
by the number (at least 5), regularity (at least twice weekly for 2 weeks), and quality of the commits
(work done, and message). You should make commits on specific micro‑goals, and have a precise
descriptive commit message for each commit. In particular, using GitHub’s web interface to upload
the files is considered as ineffective use of GitHub. Also, generic commit messages such as “Updated
the file…” or “Fixed a bug” are not considered effective either.
Mark Allocation Guidelines
Below are the general university descriptions of the different deciles.
0‑39 40‑49 50‑59 60‑69 70+ 80+
Failed to show
basic
understanding
of most topics
in the module.
Showed basic
understanding
of module
topics, weak in
places.
A mixture of
strong
elements and
weaknesses.
Generally
strong inc.
some
deeper
analysis
and
insights.
The
majority of
the work
exceeds the
standard
expected.
All work
substantially
exceeds the
standard
expected.
Dr Kamal Bentahar 2
Advanced Programming Paradigms (6008CEM) — Assignment Brief 2023
(1)
Fun
cti
on
al
Pro
gra
mm
ing
(Ha
ske
ll)
Task 1 (Haskell): Convert a Markup Language to HTML
A charity has approached you to help them convertmarked‑up texts into HTML. The texts aremade of
a sequenceofheadingsandparagraphs. Mostparagraphs startwithachainofnarrators, onenarrating
from the next, until they reach the final narrator, whose saying is to be highlighted.
The narrators are enclosed in a pattern “/d ..... LD /d”, where d and D are numbers (L is the
literal letter ‘L’).
The texts are in Arabic, but Latinised copies can be generated using the Python script la-
tinise.py.
Below is a Latinised example where the markup is shown in bold:
E1 /1musnadu aleašarati almubaššarīna bialjannati /1 /30musnadu alḵulafā’i alrrāšidīna /30 /7
musnadu ’ab bakrin alṣṣiddīqi raḍiya alllahu eanhu /7
$11 /2 /140ḥaddaṯanā /94eabdualllahi bnunumayrinL5128 /94 , qāla : ’aḵbaranā /26 ’ismāeīlu
yaen abna ’ab ḵālidin L989 /26 , ean /26 qaysin L6508 /26 , qāla : /27 qāma /93 ’ab bakrin L4945
/93 , faḥamida alllaha wa’aṯnā ealayhi , ṯumma qāla : yā ’ayyuhā alnnāsu , ’innakum taqra’ūna
haḏihi alāyata : /4 ya’ayyuh allaḏīna āmanuwa ealaykum ’anfusakum la yaḍurrukumman ḍalla
’i ahtadaytum swrt alma’dt āyt 105 /4 , wa’innā samienā rasūla alllahi ṣallā alllahu ealayhi
wasallama , yaqūlu : /20 ” ’inna alnnāsa ’iḏā ra’awa almunkara falam yuggiyirwh , ’awšaka ’an
yaeummahumu alllahu bieiqābihi ” /27 *
When this is convereted it would show like this (with the provided CSS style sheet and fonts):
The meaning of some tags:
Tag Meaning Tag Meaning Tag Meaning
/1 Heading 1 /7 Heading 2 /30 Heading 3
/26 Narrator /94 First narrator /93 Last narrator
Youarealsogivena fileinput/narrators.csv containing reliabilitygradesandshortbiograph‑
ical information on the narrators. (Header: ID,Name,Grade,Grade text,Generation,Total.)
Dr Kamal Bentahar 3
Advanced Programming Paradigms (6008CEM) — Assignment Brief 2023
(1)
Fun
cti
on
al
Pro
gra
mm
ing
(Ha
ske
ll)
Your task is to use Haskell to create a converter that mimics the Python solution convert.py pro‑
vided on the template GitHub repository under the folder T1.
The performance of convert.py defines the level of a 70%mark. Whatmatters is the HTML output,
not any error/logging messages.
You can improve or create additional functions as needed to achieve higher marks.
Regarding the non‑POSIX regex’s, you have at least two options:
1. Find a library that supports them. You are permitted to use such libraries as long as they
can be installed using stack install on Codio.
2. Design your own POSIX regex’s. Use e.g. https://regex101.com to test and debug them. (I
recommend testing them on a Latinised copy of the text to avoid any right‑to‑left issues.)
In particular, many of the “.+?” may be replaced with “[^/]+” or “[^\s/]+” – try it!
Finally, benchmark your code against the Python solution by running both of the Python and Haskell
codes on 3 input texts (small, medium, big).
Rules
• You are allowed to make use of functions from the standard library and Stackage, but ensure
your code contains the necessary import statements.
• Specify any used Stackage modules in the file MODULES.md. These must be installable using
stack install on Codio.
• Your code will be marked by the installation of Haskell on Codio with the specified modules.
• Document your benchmarking results in the file BENCHMARKS.md.
• Thecodeyouwritemustbeyourown. Youcan lookat the6008CEMCodioguideor the textbooks
recommended on Talis for help.
• List any external resources used to help you complete your work as comments in your code.
(URLs, etc.)
Marking Guidance
5 marks: Loading the narrators data, and converting it to a Map for later use.
10 marks: Converting the markup tags into their respective HTML/CSS tags (following
convert.py).
10 marks: Setting the narrator’s information (following convert.py).
5 marks: Benchmarking report
5 marks: Documentation (function type signatures, docstrings, and comments).
5 marks: Effective use of GitHub.
Working but incomplete code will be marked higher than ambitious but non‑working code.
Dr Kamal Bentahar 4
Advanced Programming Paradigms (6008CEM) — Assignment Brief 2023
(2)
Log
ic
Pro
gra
mm
ing
(Pr
olo
g)
Task 2 (Prolog): Is it cold, flu or COVID‑19? (Expert System)
“In artificial intelligence, an expert system is a computer system emulating the decision‑making
ability of a human expert. Expert systems are designed to solve complex problems by reasoning
through bodies of knowledge, represented mainly as if–then rules rather than through conven‑
tional procedural code. The first expert systems were created in the 1970s and then proliferated
in the 1980s. Expert systems were among the first truly successful forms of artificial intelligence
(AI) software.
Anexpert system isdivided into twosubsystems: the inferenceengineand theknowledgebase.
The knowledge base represents facts and rules. The inference engine applies the rules to the
known facts to deduce new facts. Inference engines can also include explanation anddebugging
abilities.” [Wikipedia, 2023]
Design and implement an Expert System (ES) in Prolog that can diagnose and provide information
on the symptoms of cold, common flu, and COVID‑19. Additionally, your ES should be able to provide
information on how tomanage the symptoms and prevent the spread of the condition to others.
Start by reading the chapter in the file “D. Crookes ‑ An application in Medicine.pdf”.
1) Create your knowledge base by coding the official NHS symptoms facts available from:
• https://www.nhs.uk/conditions/common‑cold/
• https://www.nhs.uk/conditions/flu/
• https://www.nhs.uk/conditions/coronavirus‑covid‑19/symptoms/main‑symptoms/
Add other facts and rules from reliable sources, and ensure you give citations/links to the
sources.
Alongsidediagnosis, the systemshouldbeable toaddress the followingquestionsaboutagiven
condition “C”:
– What are the common symptoms of C?
– What should I do if I have symptoms of C?
– What are the risk factors for severe illness from C?
– How can I prevent the spread of C?
– What is the difference between C1 and C2?
2) Test the system with different inputs and evaluate the accuracy of the results. Write your dis‑
cussion in EVALUATION.md.
Design and run a test suite aiming for 100% code coverage (every branch is tested).
Dr Kamal Bentahar 5
Advanced Programming Paradigms (6008CEM) — Assignment Brief 2023
(2)
Log
ic
Pro
gra
mm
ing
(Pr
olo
g)
Rules
• Your codewill bemarked by the installation of Prolog onCodiowith no additional installsmade.
• Interaction with the user should be through as‑close‑as‑possible to a natural language. (E.g.
through questions and yes/no answers, not through hard coded Prolog predicates.)
• Ensure thatwhen the program is donewith a diagnosis that it can start another sessionwithout
the old variables still being assigned in memory.
• The discussion presented in “D. Crookes ‑ An application in Medicine.pdf” uses integers to repre‑
sent percentages because floats were not supported by Prolog at the time. Youmust use floats
in your code to represent probabilities as numbers in the range [0, 1]. The formulae need to be
adjusted back to the original form to be used in your code.
• Your ES system should specialise in the three mentioned conditions only. Keep this in mind
when computing/guessing the probabilities.
• You are allowed to make use of functions from the standard library, but ensure your code con‑
tains the necessary import statements.
• You are not allowed to make use of functions from outside the standard library. Your code will
be marked by the installation of SWI‑Prolog on Codio with no additional installs made.
• The code you write should be your own. You can look at the 6008CEM Codio guide or the text‑
books recommended on Talis for help.
• List any external resources used to help you complete your work as comments in your code.
(URLs, etc.)
Marking Guidance
15 marks: Knowledge base (Facts and Rules).
5 marks: Interactive interface.
5 marks: Testing and documentation.
5 marks: Effective use of GitHub.
Dr Kamal Bentahar 6
Advanced Programming Paradigms (6008CEM) — Assignment Brief 2023
(3)
Co
nst
rai
nt
Pro
gra
mm
ing
(Z3
)
Task 3 (Z3): University Modules Allocation
The Computer Science department has a number of modules, , that must be taught, and a few
lecturers, ℓ, whomay deliver them.
• Eachmodule must be delivered by exactly one lecturer.
• No lecturer should need to teach more than modules at the same time, for some fixed value
of .
• No module should be taught by a lecturer with expertise 1 or less.
Each lecturer has been invited to rate their expertise on the modules on a linear 0 to 5 scale (with 5
being most expert).
The following table shows an example of expertise weighting of 6 lecturers’ for 20 modules:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
ℓ1 5 4 1 2 0 5 0 5 2 3 4 0 2 3 2 4 5 1 4 3
ℓ2 3 4 2 0 4 0 0 5 3 5 5 5 0 4 3 2 1 5 2 5
ℓ3 0 1 4 1 1 1 4 3 0 0 2 4 3 0 2 4 2 5 0 4
ℓ4 2 4 1 4 4 4 2 3 0 4 3 2 4 1 2 1 1 1 0 4
ℓ5 5 2 3 0 0 5 1 1 0 0 5 4 5 3 5 4 2 4 1 1
ℓ6 5 4 3 4 2 3 3 5 5 5 2 0 2 4 0 3 4 5 2 1
Wewould like to allocate modules to lecturers tomaximise expertise.
Use Python and Z3 to identify an allocation of modules to lecturers that has the maximum possible
expertise, for any given set of modules, lecturers and .
Your solution should be in a single Python script, named allocations.py, which when executed
prints the answer to the terminal. (Both the lecturer‑modules allocations and resulting total expertise
used).
Dr Kamal Bentahar 7
Advanced Programming Paradigms (6008CEM) — Assignment Brief 2023
(3)
Co
nst
rai
nt
Pro
gra
mm
ing
(Z3
)
Rules
• Youare allowed tomakeuseof functions fromthePython standard library or theZ3module (the
version installed on Codio). Make sure your code contains the necessary import statements.
• You are not allowed tomake use of functions from outside the standard library other than from
the Z3 module. Your code will be marked by the installation of Python3 on Codio with no addi‑
tional installs made.
• Thecodeyouwritemustbeyourown. Youcan lookat the6008CEMCodioguideor the textbooks
recommended on Talis for help.
• List any external resources used to help you complete your work as comments in your code.
(URLs, etc.)
Marking Guidance
10 marks: Z3 code to find a feasible solution.
10 marks: Z3 code to find an optimal solution.
5 marks: Documentation (function encapsulation, docstrings, and comments)
5 marks: Effective use of GitHub.
Dr Kamal Bentahar 8
Advanced Programming Paradigms (6008CEM) — Assignment Brief 2023
Ge
ne
ral
ass
ess
me
nt
no
tes
General assessment notes
The following general CU Assessment notes have been specified to this task.
1. Referencing – List any external resources used to help you complete your work as comments in
your code. (URLs, etc.)
2. Please notify your Registry course support team and Module Leader for disability support.
3. Any student requiring an extension or deferral should follow the university process as outlined
here: https://livecoventryac.sharepoint.com/sites/students‑registry‑extensions‑deferrals
4. TheUniversity cannot take responsibility for any coursework lost or corrupted on disks, laptops
or personal computer. Students should therefore regularly back‑up any work, and are advised
to save it on the University system. Note that CU GitHub and Codio can serve as an (automatic)
backup.
5. If there are technical or performance issues that prevent students submitting coursework
through the online coursework submission system on the day of a coursework deadline, an
appropriate extension to the coursework submission deadline will be agreed. This extension
will normally be 24 hours or the next working day if the deadline falls on a Friday or over the
weekend period. This will be communicated via your Module Leader.
6. Youworkmust be your own and original: it will be compared against thework of other students
and the internet using Turnitin and other tools.
7. Collusion between students (where sections of your work are similar to the work submitted
by other students in this or previous module cohorts) is taken extremely seriously and will be
reported to the academic conduct panel. This applies to both coursework and test answers.
8. Amarkeddifferencebetweenyourwriting style, knowledgeand skill level demonstrated in class
discussion, any test conditions and that demonstrated in a coursework assignment may result
in you having to undertake a Viva Voce in order to prove the coursework assignment is entirely
your own work.
9. You must not submit work for assessment that you have already submitted (partially or in
full), either for your current course or for another qualification of this university, with the
exception of resits, where for the coursework, you may be asked to rework and improve a
previous attempt. This requirement will be specifically detailed in your assignment brief or
specific course or module information. Where earlier work by you is citable, i.e. it has already
been published/submitted, you must reference it clearly. Identical pieces of work submitted
concurrently may also be considered to be self‑plagiarism
10. The use of generative AI in any assessment is forbidden, unless explicitly allowed in the assign‑
ment brief.
Dr Kamal Bentahar 9
Advanced Programming Paradigms (6008CEM) — Assignment Brief 2023
Pla
gia
rism
an
dL
ate
sub
mi
ssi
on
Plagiarism
Plagiarism is very serious. Make sure you avoid it!
• The following is not considered as plagiarism:
– Discussing the project and possible strategies with other students.
– Looking at online resources for examples of programming techniques.
• However, the following is considered plagiarism:
– Copying code, or parts of code, from other students.
– Copying code, or parts of code, from Internet sites/videos. (Unless made clear with a cita‑
tion.)
If you need further guidance on what is or is not plagiarism then ask a member of staff.
All submissions are checked for similarity. Any student found to have plagiarised will receive zero
marks, and will be reported to the Academic Conduct Office for a disciplinary procedure.
Late submission
Note that late submissions receive a zero mark.
Dr Kamal Bentahar 10