repo
stringlengths
26
115
file
stringlengths
54
212
language
stringclasses
2 values
license
stringclasses
16 values
content
stringlengths
19
1.07M
https://github.com/detypstify/detypstify
https://raw.githubusercontent.com/detypstify/detypstify/main/paper/main.typ
typst
#import "@preview/tablex:0.0.8": cellx, hlinex, tablex #import "neurips2023.typ": * #import "logo.typ": LaTeX, LaTeXe, TeX #let yale = (department: none, institution: "Yale", location: none) #let affls = ("yale": yale) #let authors = ( ( name: "<NAME>", affl: "yale", email: "<EMAIL>", equal: true, ), ( name: "<NAME>", affl: "yale", email: "<EMAIL>", equal: true, ), ) #show: neurips2023.with( title: "Detypstify: OCR for formula generation", authors: (authors, affls), keywords: ("Machine Learning", "NeurIPS"), // one paragraph only abstract: [ Optical Character Recognition (OCR) has seen widespread use in the past few years. It has been used for data entry automation, document management, and even in the medical field for digitizing medical records. OCR makes the tasks both faster and less error prone. In this paper, we present Detypstify, a tool which uses state-of-the-art OCR to generate math formulas from images. The problem of generating LaTeX formulas from images is not new, in fact it forms the basis of the OpenAI Im2Latex problem which was posted as part of the first request for research @openai. Detypstify tackles this problem in a new way by using a transformer based model. We deploy this model using Web Assembly and WGPU to allow for client side computation. ], bibliography: bibliography("main.bib"), bibliography-opts: (title: "References", full: true), // Only for example paper. accepted: true, ) = Introduction In recent years, Optical Character Recognition (OCR) technology has revolutionized various domains by streamlining tasks, reducing errors, and enhancing efficiency. From automating data entry to facilitating document management, OCR has proven indispensable across diverse industries. Moreover, its applications extend into the realm of healthcare, where it aids in the digitization of medical records, contributing to the modernization of healthcare systems. Amidst this landscape, the demand for innovative OCR solutions continues to grow. This paper introduces Detypstify, a novel tool designed to address the challenge of generating mathematical formulas from images using state-of-the-art OCR technology. While the task of converting images to LaTeX formulas is not new, Detypstify distinguishes itself through its utilization of a transformer-based model. This approach marks a departure from traditional methods and builds upon the foundation laid by initiatives such as the OpenAI Im2Latex problem, which has stimulated research in this domain. Detypstify leverages Web Assembly and WGPU for deployment, enabling client-side computation and enhancing accessibility. By harnessing the power of these technologies, Detypstify not only offers a sophisticated solution but also ensures seamless integration into existing workflows. This paper provides an overview of the design, implementation, and performance of Detypstify, underscoring its potential to advance the field of OCR and mathematical representation. = Background and Related Work == Model Fine tuning of large models has proven to be an effective way of achieving state-of-the-art performance on a wide range of tasks @finetuning-good2. This performance is often better than smaller models dedicated to this particular task @finetuning-good1. As a result, we decided to fine-tune a large model for our task as well. Text recognition is usually done either with Convolutional Neural Networks (CNN) or with Recurrent Neural Networks (RNN). We decided to diverge from the conventional approach and use a transformer based model. TrOCR @trocr, transformer based optical character recognition, is a model which outperforms the state-of-the-art in OCR tasks, both handwritten and printed. As such we decided to use this model as our base model for fine tuning. == Other formula generation tools While there are several other tools which implement the same functionality as Detypstify, Detyptify has several features which distinguish it from the competition. + *Support for Typst*, there are no tools which generate Typst formulas from images. + *Web Assembly*, Detypstify is deployed using Web Assembly which allows for deployment as a static website without a backend. All computation is performed by the client which we haven't seen in other tools. + *Transformer based OCR*, most tools use CNN or RNN based OCR, Detypstify uses a transformer based OCR. == Method description == Model === Dataset At the time of writing, there were no available datasets of images of formulas and their corresponding Typst encoding. We created our own dataset by converting the formulas from the Im2Latex dataset @dataset which has been widely used for similar tasks when converting to LaTeX. The bulk of the conversion was done using Pandoc, however, the conversion was not perfect and required several correction passes to ensure valid Typst formulas. This was because, to our knowledge, none of the datasets were generated post-Latex2e which led to several incompatibilities with Pandoc. The final dataset is available on Kaggle @typst-dataset. === Training We fine tuned the TrOCR model on our dataset using native PyTorch with the VisionEncoderDecorerModel class. The model was trained on a single Nvidia GeForce RTX 4090 GPU for 7 epochs with a batch size of 1 because of VRAM memory constraints. We could not fit the model and more than one image into VRAM at a time. To evalutate the model we use the Character Error Rate (CER) which is the number of incorrect characters divided by the total number of characters. This turned out to be a poor metric for our task. Our second attempt at training a model was using the Vision Transformer (ViT) model from scratch @latex_ocr. We chose this implementation as it performed well for generating LaTeX code. The ViT model was trained on the same system as the TrOCR model with the same batch size, but since we are training from scratch we train for 25 epochs. == Webapp == ONNX ONNX is a standardized format for representing machine learning models. We export our trained model to ONNX so that we can integrate it with the rest of the application. == Burn Burn is a machine learning framework written in Rust, compatible with the ONNX model format. Burn is in active development and some of the necessary operations of the ONNX framework were not supported (`expand`, `slice`, `squeeze`, `range`, `less`, `constantofshape`). We confirmed with the developers of Burn that these operations were not supported. The developers are working to add support. Once these operations are supported, integration is a simple include. == Wasm + WGPU One of the main draws of using Web Assembly is the ability to run machine learning models in the browser on the client side. This means that we are not required to host a backend and can simple host the web assembly binary. The client will then download the binary and run the model locally. To compliment this portability, we use WGPU, a Rust library for interfacing with GPUs. This allows the user to run the model on any hardware that has a GPU (for example, a phone or laptop) without having to install any libraries. = Results & Discussion == TrOCR Fine Tuning Although the fine-tuning took a week and a half, the results were quite disappointing. The model was unable to predict even single characters like $alpha$. This is likely due to the Character Error Rate (CER) which works very well on handwriting and extracting the formulas themselves. Since we are mapping images to code and not text, we do not have a bijection between the input and the output. As a result the model doesn't perform well. Armed with these insights, we decited to try training a model from scratch on the Typst dataset == ViT Trainig After training the model for 25 epochs, which corresponds to around 48 GPU hours, the accuracy plateaued at 2% which is nowhere near the level required to make the tool usable. This is likely due to our lack of experience with the ViT model which led to poor hyperparameter choices. We are reaching out the authors of LaTeX OCR to see if they can provide us with the hyperparameters they used to train their model and try again. = Conclusion We present Detypstify, a tool that uses OCR for formula generation. We fine tune a transformer based large model for this task and deploy it statically using Web Assembly and WGPU. Our results are not as good as we hoped, but with the help of the authors of LaTeX OCR we hope to improve the performance and make the tool usable. The deployment framework is ready, but with no model to deploy it is not very useful. After we improve the model we will deploy it and make it available to the public. We hope that this tool will eventually be useful for the Typst community. #pagebreak()
https://github.com/dark-flames/resume
https://raw.githubusercontent.com/dark-flames/resume/main/data/project.typ
typst
MIT License
#import "../libs.typ": * #import "../chicv.typ": * #let projectList = ( ( name: "yukino", cv-content: true, resume-content: true, link: iconlink("https://github.com/dark-flames/yukino-dev", icon: github, text: "yukino-dev"), intro: "A type-driven and high-performance ORM framework in Rust", content: [ - Derived SQL operations from simple Rust code based on a monadic structure. - Developed a functional query builder that delegates its type-checking to the type system of Rust. - Provided a zero-cost abstraction that ensures both efficiency and type safety. ], ), ( name: "toy-dt-cpp", cv-content: true, resume-content: true, link: iconlink("https://github.com/dark-flames/top-dt-cpp", icon: github, text: "top-dt-cpp"), intro: "A simple dependently typed language implementation in C++", content: [], ), ( name: "quote-data", cv-content: true, resume-content: true, link: iconlink("https://github.com/dark-flames/quote-data", icon: github, text: "quote-data"), intro: "A tokenization library for procedural macros in Rust", content: [], ), ( name: "annotation-rs", cv-content: true, resume-content: true, link: iconlink("https://github.com/dark-flames/annotation-rs", icon: github, text: "annotation-rs"), intro: "Compile-time annotation parser for Rust", content: [], ), ( name: "derivation-resolver", cv-content: true, resume-content: false, link: iconlink("https://github.com/dark-flames/derivation-resolver", icon: github, text: "derivation-resolver"), intro: "Derivation tree resolver for STLC and System F in Rust", content: [], ), ( name: "riscv-cpu", cv-content: false, resume-content: true, link: iconlink("https://github.com/dark-flames/RISCV-CPU", icon: github, text: "RISCV-CPU"), intro: "Assignment project, a pipelined RISC-V CPU in Verilog", content: [], ), ) #let project(env) = { multiLang(env, en: [== Personal Projects], cn: [== 个人项目]) let content = if(not show-cv-content(env)) { projectList.filter(i => not i.cv-content or i.resume-content) } else { projectList } if(not show-resume-content(env)) { content.filter(i => not i.resume-content or i.cv-content) } else { content }.map(i => { cventry( tl: [*#i.name*, #i.intro], tr: i.link, )[#i.content] }).join() }
https://github.com/Lucas-Wye/tech-note
https://raw.githubusercontent.com/Lucas-Wye/tech-note/main/src/howtosearch.typ
typst
= How to use search engine #label("how-to-use-search-engine") - Search engines are systems that enable users to search for documents on the World Wide Web. - Popular examples include Yahoo!Search, Bing, Google, and Ask.com. == 特殊符号 #label("特殊符号") #strong[双引号]:把搜索词放在双引号中,代表#strong[完全匹配搜索](顺序也必须完全匹配) eg: "浙江大学SCDA" #strong[减号]:搜索不包含减号后面的词的页面,使用这个指令时减号前面必须是#strong[空格],减号后面没有空格,紧跟着需要排除的词 eg: 浙江大学 -学院 #strong[星号]:通配符 eg: 浙\*大学 #strong[inurl]:查找网址中包含指定字符的页面 eg: inurl:nice #strong[inanchor]:查找导入链接锚文字中包含搜索词的页面 eg: inanchor:点击这里 #strong[intitle]: 查找页面title 中包含关键词的页面 eg: intitle: 查老师 #strong[filetype]:查找特定格式文件 eg: filetype:pdf SCDA #strong[site]: 搜索某个域名下的所有子路径 eg: site: www.zju.edu.cn == 快照功能 #label("快照功能") 搜索引擎在收录网页时,对网页进行备份,存在自己的服务器缓存里,由于网页快照是存储在搜索引擎服务器中,所以查看网页快照的速度往往比直接访问网页要快 eg: 高斯分布 site:zh.wikipedia.org == 特殊搜索 #label("特殊搜索") - 中文文献 \ #link("http://xueshu.baidu.com")[百度学术] \ #link("https://cn.bing.com/academic?mkt=zh-CN")[bing学术] \ #link("https://scholar.google.com")[谷歌学术] - 英文文献 \ #link("https://cn.bing.com/academic?mkt=zh-CN")[bing学术] \ #link("https://scholar.google.com")[谷歌学术] \ #link("https://sci-hub.tw")[Sci-hub] \ #link("http://ieeexplore.ieee.org")[IEEE] - 编程相关 \ #link("http://github.com")[github] \ #link("https://medium.com")[medium] \ #link("http://stackoverflow.com")[stackoverflow] == 深度搜索 #label("深度搜索") 特殊的搜索工具可以搜索#strong[深网]的内容 微信搜索 https://weixin.sogou.com Archive搜索引擎 http://archive.org Wikihow #link("https://zh.wikihow.com/搜索深网") more https://www.freebuf.com/news/137844.html == More #label("more") #link("https://github.com/Lucas-Wye/Share/blob/master/search.pdf")[search.pdf] \ #link("https://www.zhihu.com/question/19847393")[搜索引擎有哪些常用技巧] \ #link("https://zhuanlan.zhihu.com/p/33188000")[深网搜索引擎]
https://github.com/JosephBoom02/Appunti
https://raw.githubusercontent.com/JosephBoom02/Appunti/main/Anno_3_Semestre_1/Controlli%20Automatici/ControlliAutomatici.typ
typst
#import "@preview/physica:0.9.0": * #import "@preview/i-figured:0.2.3" #import "@preview/cetz:0.1.2" #import "@preview/xarrow:0.2.0": xarrow #import cetz.plot #let title = "Controlli Automatici T" #let author = "<NAME>" #set document(title: title, author: author) #cetz.canvas({ import cetz.draw: * // Your drawing code goes here }) #show math.equation: i-figured.show-equation.with(level: 2, only-labeled: true) #show link: set text(rgb("#cc0052")) #show ref: set text(green) #set page(margin: (y: 0.5cm)) #set heading(numbering: "1.1.1.1.1.1") //#set math.equation(numbering: "(1)") #set math.mat(gap: 1em) //Code to have bigger fraction in inline math #let dfrac(x,y) = math.display(math.frac(x,y)) //Equation without numbering (obsolete) #let nonum(eq) = math.equation(block: true, numbering: none, eq) //Usage: #nonum($a^2 + b^2 = c^2$) #let space = h(5em) //Shortcut for centered figure with image #let cfigure(img, wth) = figure(image(img, width: wth)) //Usage: #cfigure("Images/Es_Rettilineo.png", 70%) #let nfigure(img, wth) = figure(image("Images/"+img, width: wth)) //Code to have sublevel equation numbering /*#set math.equation(numbering: (..nums) => { locate(loc => { "(" + str(counter(heading).at(loc).at(0)) + "." + str(nums.pos().first()) + ")" }) },) #show heading: it => { if it.level == 1 { counter(math.equation).update(0) } }*/ // //Shortcut to write equation with tag aligned to right #let tageq(eq,tag) = grid(columns: (1fr, 1fr, 1fr), column-gutter: 1fr, [], math.equation(block: true ,numbering: none)[$eq$], align(horizon)[$tag$]) // Usage: #tageq($x=y$, $j=1,...,n$) // Show title and author #v(3pt, weak: true) #align(center, text(18pt, title)) #v(8.35mm, weak: true) #align(center, text(15pt, author)) #v(8.35mm, weak: true) #outline() //Justify text = Introduzione L'idea dei #text(weight: "bold")[controlli automatici] è sostituire l'intelligenza umana con un sistema automatico (come l'intelligenza artificiale) basata su leggi matematiche e/o algoritmi. == Notazione ed elementi costitutivi #figure(image("Images/Schema_sistema.png" ,width: 50%)) Il #text(weight: "bold")[sistema] è un oggetto per il quale si vuole ottenere un comportamento desiderato. Esempi di sistema sono: impianto (industriale), macchinario (braccio robotico, macchina a controllo numerico, etc ...), veicolo (auto, velivolo, drone, etc ...), fenomeno fisico (condizioni atmosferiche), sistema biologico, sistema sociale. L'obiettivo è che l'andamento nel tempo di alcune variabili segua un segnale di riferimento. Altri elementi sono: - Controllore: unità che determina l'andamento della variabile di controllo (ingresso); - Sistema di controllo: sistema (processo) + controllore; - Sistemi di controllo naturali: meccanismi presenti in natura, come quelli presenti nel corpo umano (temperatura corporea costante, ritmo cardiaco, etc dots); - Sistemi di controllo manuali: è presente l'azione dell'uomo; - Sistemi di controllo automatico: uomo sostituito da un dispositivo. == Controllo in anello aperto e anello chiuso Controllo in anello aperto *“feedforward”*: il controllore utilizza solo il segnale di riferimento #figure(image("Images/Anello_aperto.png", width: 75%)) #text(weight: "bold")[Controllo in anello chiuso] (“*feedback*” o retroazione): il controllore utilizza il segnale di riferimento e la variabile controllata ad ogni istante di tempo #figure(image("Images/Anello_chiuso.png", width: 80%)) Il controllo in retroazione è un paradigma centrale nei controlli automatici. == Progetto di un sistema di controllo I passi per progettare un sistema di controllo sono: - definizione delle specifiche: assegnazione comportamento desiderato, qualità del controllo, costo,... - modellazione del sistema (controllo e test): complessità del modello (compromesso), definizione ingressi/uscite, codifica del modello, validazione in simulazione - analisi del sistema: studio proprietà “strutturali”, fattibilità specifiche - sintesi legge di controllo: è basata su modello, analisi sistema controllato, stima carico computazionale - simulazione sistema controllato: test su modello di controllo, test realistici (modello complesso, ritardi, quantizzazione, disturbi, ...) - scelta elementi tecnologici: sensori/attuatori, elettronica di acquisizione/attuazione, dispositivo di elaborazione - sperimentazione: hardware in the loop, prototipazione rapida, realizzazione prototipo definitivo == Esempio di sistema di controllo: circuito elettrico <Circuito_elettrico> #figure(image("Images/Es_circuito_elettrico.png", width: 35%)) La legge che usiamo per definire il circuito (il nostro sistema) è la #text(style: "italic")[legge delle tensioni] $ v_R (t) = v_G (t) - v_C(t) $ le leggi del condensatore e del resistore sono $ C dot dot(v)_C (t) = i(t) #h(2cm) v_R (t) = R dot i(t) $ Scrivendo la formula in termini di $v_C (t)$ (stato interno) e $v_G (t)$ (ingresso di controllo) $ dot(v)_C (t) = 1 / "RC" (v_G (t) - v_C (t)) $ = Sistemi in forma di stato == Sistemi continui I #text(style: "italic")[sistemi continui] sono sistemi in cui il tempo è una variabile reale: $t in RR$ $ dot(x)(t) &= f ( x(t), u(t), t ) #h(3em) && "equazione di stato" \ dot(y)(t) &= h(x(t), u(t), t) && "equazione (trasformazione) di uscita" $ <sistemi_continui> Definiamo inoltre $t_0$ come tempo iniziale e $x(t_0)=x_0$ come stato iniziale. #text(weight: "bold")[N.B.] $dot(x)(t) := display(frac(d, d t)) x(t)$. Notazione: - $x(t) in RR^n$ stato del sistema all'istante $t$ - $u(t) in RR^m$ ingresso del sistema all'istante $t$ - $y(t) in RR^p$ uscita del sistema all'istante $t$ $ x(t)= mat(delim: "[", x_1(t); dots.v; x_n(t)) #h(3.5em) u(t) = mat(delim: "[", u_1(t); dots.v; u_m(t)) #h(3.5em) y(t) = mat(delim: "[", y_1(t); dots.v; y_p(t)) $ Da notare che $x(t)$ è un vettore mentre $x_1,...,x_n$ sono scalari; $x(t)$ è una variabile interna che descrive il comportamento del sistema. === Equazione di stato L #text(style: "italic")[equazione di stato] è un'equazione differenziale ordinaria (ODE) vettoriale del primo ordine (cioè l'ordine massimo delle derivate è 1) $ dot(x)_1(t) &= f_1 (mat(delim: "[", x_1 (t); dots.v; x_n (t)), mat(delim: "[", u_1 (t); dots.v; u_m (t)), t) \ &dots.v \ dot(x)_n (t) &= f_n (mat(delim: "[", x_1 (t); dots.v; x_n (t)), mat(delim: "[", u_1 (t); dots.v; u_m (t)), t) $ $RR^n$ è detto #underline[spazio di stato], con $n$ ordine del sistema. La funzione di stato è $f: RR^n times RR^m times RR -> RR^n$. $ mat(delim: "[", dot(x)_1(t); dots.v; dot(x)_n(t); ) = mat(delim: "[", f_1 (x(t),u(t),t); dots.v; f_n (x(t),u(t),t); ) := f (x(t),u(t),t) $ Avere solo derivate prime non è limitato, perché ad esempio posso inserire una prima variabile come derivata prima e una seconda variabile come derivata prima della prima variabile. === Equazione di uscita L'equazione di uscita è un'equazione algebrica $ y_1(t) &= h_1 (x(t), u(t), t) \ &dots.v \ y_p (t) &= h_p (x(t), u(t), t) $ $h : RR^n times RR^m , RR -> RR^p$ funzione di uscita $ mat(delim: "[", y_1(t); dots.v; y_p (t) ) = mat(delim: "[", h_1 (x(t),u(t),t); dots.v; h_p (x(t),u(t),t) ) := h(x(t),u(t),t) $ Se la soluzione $x(t)$ a partire da un istante iniziale $t_0$ è univocamente determinata da $x(t_0)$ e $u(tau)$ con $tau >= t_0$, allora il sistema è detto #text(weight: "bold")[causale], cioè lo stato dipende solo da ciò che accede in passato. Sotto opportune *ipotesi* di regolarità della funzione $f$ si dimostra esistenza e unicità della soluzione dell'equazione (differenziale) di stato (Teorema di Cauchy-Lipschitz). == Sistemi discreti Nei _sistemi discreti_ il tempo $t$ è una variabile interna, $t in ZZ$. $ x(t+1) &= f (x(t), u(t), t ) #h(3.5em) && "(equazione di stato)" \ y(t) &= h (x(t), u(t), t ) && "(equazione (trasformazione) di uscita)" $ <sistemi_discreti> L'equazione di stato è un'equazione alle differenze finite (FDE). Notazione: - $x(t) in RR^n$ stato del sistema all'istante $t$ - $u(t) in RR^m$ ingresso del sistema all'istante $t$ - $y(t) in RR^p$ uscita del sistema all'istante $t$ $x(t),u(t)" e " y(t)$ sono uguali ai sistemi continui. Per modellare sistemi discreti nel codice basta un ciclo ```matlab for ```. == Esempio circuito elettrico Riprendiamo l'esempio del @Circuito_elettrico[circuito elettrico]; la formula trovata è $ underbrace(dot(v)_C(t), dot(x)(t)) = frac(1,R C) lr((underbrace(v_G (t),u(t)) - underbrace(v_C (t),x(t))), size: #35%) $ In questo caso lo stato del sistema $x(t)$ è caratterizzato dalla variabile $v_C (t)$, l'ingresso dalla variabile $v_G (t)$. Supponiamo quindi di misurare (con un sensore) la tensione ai capi della resistenza, allora l'uscita del nostro sistema sarà $v_R (t)$ $ dot(x)(t) &= frac(1, R C) (u(t)-x(t)) #h(4em) f(x,u) &&= frac(1, R C)(u-x) $ da notare che in questo caso $f$ non è funzione del tempo. $ v_R (t) = v_G (t) - v_C (t) ==> y(t) = u(t) - x(t) $ === Esempio con parametri che variano nel tempo Supponiamo che la resistenza sia una funzione del tempo $ R(t) = overline(R) (1- frac(1,2) e^(-t) ) $ allora $ dot(x)(t) &= frac(1,R(t)C) (u(t)-x(t) ) #h(3.5em) f(x,u,t) &= frac(1,R(t)C)(u-x) $ in questo caso $f$ è funzione del tempo. == Esempio carrello #figure(image("Images/Es_carrello.png", width: 40%)) La legge che usiamo è la legge di Newton, prendendo $z$ come posizione del centro di massa $ M dot.double(z) = -F_e + F_m $ con $M$ massa e $F_e$ data da $ F_e (z(t), t) = k(t)z(t) $ quindi la nostra equazione diventa $ M dot.double(z)(t) = -k(t)z(t) + F_m (t) $ Siccome nella nostra formula compare una derivata seconda di una variabile ci conviene definire lo stato del sistema con la variabile stessa e la derivata prima della variabile. Definiamo quindi $x_1 := z$ e $x_2:=dot(z)$, con stato $x := [x_1x_2]^T$, e $u := F_m$ (ingresso). Quindi possiamo scrivere, tenendo conto che $dot(x)_2(t) = dot.double(z)$ $ dot(x)_1(t) &= x_2(t) \ dot(x)_2(t) &= - frac(k,M) x_1(t) + frac(u(t),M) $ $ f(x,u) = mat(delim: "[", f_1(x,u); f_2(x,u); ) := mat(delim: "[", x_2; - display(frac(k,M))x_1+ display(frac(u,M)); ) $ Supponiamo di misurare $z(t)$ (sensore posizione), allora $y := z$ $ dot(x)_1(t) &= x_2(t) \ dot(x)_2(t) &= - frac(k,M) x_1(t) + frac(u(t),M) \ y(t) &= x_1(t) $ Sia $k(t) = k$ e, ricordando la formula dell'energia cinetica $E_(k)=display(frac(1,2)) m v^(2)$ e la formula dell'energia elastica $U= display(frac(1,2)) k Delta x^2$, consideriamo come uscita l'energia totale $E_T (t) = display(frac(1,2)) (k z^2 (t) + M dot(z)^2 (t))$ $ dot(x)_1(t) &= x_2(t) \ dot(x)_2(t) &= - frac(k,M) x_1(t) + frac(u(t),M) \ y(t) &= frac(1,2) (k(t) x_1^2 (t) + M x_2^2 (t) ) $ quindi $h(x):= dfrac(1,2) (k x_1^2 + M x_2^2)$. *N.B.* Il risultato (l'uscita) vale, di solito, solo per il mio modello, in base a come l'ho impostato; nella realtà potrebbe essere diverso. == Esempio auto in rettilineo #cfigure("Images/Es_Rettilineo.png", 60%) Scriviamo la legge di Newton $ M dot.double(z) = F_"drag" + F_m $ con $M$ massa e $F_"drag"$ data da $ F_("drag") = -b dot(z) $ Definiamo $x_1 := z$ e $x_2 := dot(z)$ $("stato" x := [x_1 x_2 ]^T )$ e $u := F_m$ (ingresso). Supponiamo di misurare $z(t)$ (sensore posizione), allora $y := z$ $ dot(x)_1(t) &= x_2(t) \ dot(x)_2(t) &= - frac(b,M) x_2(t) + frac(1,M)u(t) \ y(t) &= x_1(t) $ Proviamo a progettare un sistema per il _cruise control_. L'equazione della dinamica è $ M dot.double(z)(t) = -b dot(z)(t) + F_m (t) $ Siccome siamo interessati a controllare la velocità e non la posizione, allora consideriamo come stato solo la velocità: $x := dot(z)$, $u := F_m$. Supponiamo di misurare $ dot(z)(t)$ (sensore velocità), allora $y := x$ $ dot(x)(t) &= -frac(b,M)x(t) + frac(1,M)u(t) \ y(t) &= x(t) $ == Esempio pendolo #cfigure("Images/Es_pendolo.png", 25%) Scriviamo l'equazione dei momenti $ M ell^2 dot.double(theta)= C_"grav" + C_"drag" + C_m $ con $M$ massa e $C_"grav"$ e $C_"drag"$ date da $ C_"grav" &=M g ell sin( theta) & #h(5em) C_"drag" &= -b dot theta $ con $b$ coefficiente d'attrito. Scriviamo l'equazione della dinamica, partendo dalla formula iniziale dei momenti $ dot.double(theta)(t) = - frac(g, ell) sin ( theta(t) ) - frac(b,M ell^2) dot(theta)(t) + frac(1,M ell^2) C_m (t) $ Definiamo quindi $x_1 := theta$ e $x_2 := dot(theta)$ (stato $x:= [x_1x_2]^T$) e $u := C_m$ (ingresso). Supponiamo di misurare $ theta$ (sensore angolo) , allora $y := theta$ $ dot(x)_1 (t) &= x_2(t) \ dot(x)_2(t) &= - frac(g, ell) sin (x_1(t) ) - frac(b,M ell^2) x_2(t) + frac(1,M ell^2) u(t) \ y(t) &= x_1(t) $ Se misuriamo invece la posizione verticale, allora $y := - ell cos(theta)$ $ dot(x)_1 (t) &= x_2(t) \ dot(x)_2(t) &= - frac(g, ell) sin (x_1(t) ) - frac(b,M ell^2) x_2(t) + frac(1,M ell^2) u(t) \ y(t) &= - ell cos( theta) $ == Traiettoria di un sistema <traiettoria_di_un_sistema> Dato un istante iniziale $t_0$ e uno stato iniziale $x_(t_0)$, la funzione del tempo $(x(t), u(t)), t>t_0$, che soddisfa l'equazione di stato $ dot(x)(t) = f (x(t), u(t), t)$ si dice traiettoria (movimento) del sistema. In particolare, $x(t)$ si dice traiettoria dello stato. Consistentemente, $y(t)$ si dice traiettoria dell'uscita. *N.B.* per sistemi senza ingresso (quindi non forzati) la traiettoria dello stato $x(t), t>t_0$ è determinata solo dallo stato iniziale $x_(t_0)$. === Esempio Definiamo un sistema con stato $x$ e stato iniziale $x_0$ $ x &:= mat(delim: "[", x_1; x_2; ) #h(5em) x_0 &:= mat(delim: "[", 5; 3; ) #h(5em) t_0 &= 0 $ $ dot(x)_1(t) &= x_2(t) \ dot(x)_2(t) &= u(t) $ Assegno a $x_1$, $x_2$ e $u(t)$ le seguenti equazioni $ overline(x)_1(t) &= 5+3t+t^2 \ overline(x)_2(t) &= 3+2t \ overline(u)(t) &= 2 $ Se le equazioni di $ overline(x)_1$ e $ overline(x)_2$ soddisfano le condizioni iniziali e la funzione di stato ($dot(x)_1$ e $dot(x)_2$) allora quelle equazioni sono la traiettoria del sistema. Infatti $ & overline(x_0) = mat(delim: "[", 5+3t+t^2; 3+2t )_(t=0) = mat(delim: "[", 5; 3 ) #h(5em) frac(d,d t) mat(delim: "[", 5+3t+t^2; 3+2t ) = mat(delim: "[", 3+2t; 2 ) $ == Equilibrio di un sistema Dato un #underline[sistema (non forzato)] $dot(x)(t) = f (x(t), t)$, uno stato $x_e$ si dice _equilibrio del sistema_ se $x(t) = x_e$ , $t >= t_0$ è una traiettoria del sistema. Dato un #underline[sistema (forzato)] $dot(x)(t) = f (x(t), u(t), t)$, $(x_e , u_e )$ si dice _coppia di equilibrio_ del sistema se $(x(t), u(t)) = (x_e , u_e )$, $t >= t_0$ , è una traiettoria del sistema. Per un #underline[sistema (tempo invariante continuo)] $dot(x)(t) = f (x(t), u(t))$ data una coppia di equilibrio $(x_e,u_e)$ vale $f(x_e,u_e)=0$. Se il sistema è non forzato, dato un equilibrio $x_e$ vale $f(x_e)=0$. === Esempio pendolo $ dot(x)_1(t) &= x_2(t) &= f_1(x(t),u(t)) \ dot(x)_2(t) &= - frac(G, ell) sin (x_1(t)) - frac(b,M ell ^2)x_2(t) + frac(1,M ell^2)u(t) #h(4em) &=f_2(x(t),u(t)) $ Siccome sappiamo che, data una coppia di equilibrio $(x_e,u_e)$, vale $f(x_e,u_e)=0$, allora per trovare l'equilibrio del pendolo imponiamo $ f(x_e,u_e)=0 $ cioè: $ cases( x_(2e)(t) = 0 \ - dfrac(G, ell) sin (x_(1e)) - dfrac(b x_(2e),M ell ^2) + dfrac(1,M ell^2)u_e =0 ) $ sostituendo $x_(2e)(t)=0$ nell'ultima equazione $ - dfrac(G, ell) sin (x_(1e)) + dfrac(1,M ell^2)u_e =0 ==> u_e = M G ell sin(x_(1e)) $ In conclusione, le coppie di equilibrio del sistema sono tutti gli $(x_(1e), x_(2e),u_e)$ che soddisfano $ cases( u_e = M G ell sin(x_(1e)) \ x_(2e)=0 ) $ == Classificazione dei sistemi in forma di stato La classe generale è $x in RR^n , u in RR^m , y in RR^p$ $ dot(x)(t) &= f (x(t), u(t), t) &space & "equazione di stato"\ y(t) &= h(x(t), u(t), t) & & "equazione di uscita" $ <sistemi_forma_stato> - I sistemi *monovariabili* (SISO, Single Input Single Output) sono una sottoclasse di sistemi *multivariabili* (MIMO, Multiple Input Multiple Output); sono tali se $m=p=1$, altrimenti sono dei sistemi MIMO; - I sistemi *strettamente propri* sono una sotto classe dei *sistemi propri*; sono tali se $y(t) = h(x(t),t)$, quindi se l'uscita dipende esclusivamente dall'ingresso, chiamati quindi sistemi causali (tutti i sistemi che abbiamo visto fin'ora sono sistemi propri). - I sistemi *non forzati* sono una sotto classe dei *sistemi forzati*; un esempio di sistema non forzato è il seguente $ dot(x)(t) &= f(x(t),t) \ y(t) &= h(x(t),t) $ - I sistemi *tempo invarianti* sono una sotto classe di sistemi *tempo varianti*; sono sistemi in cui le funzioni $f$ e $h$ #underline[non dipendono esplicitamente] dal tempo, cioè risulti $ dot(x)(t) = f(x(t), u(t)) \ y(t) = h(x(t), u(t)) $ I tempo invarianti sono tali se, data una traiettoria $ (x(t), u(t)), t >= t_0$, con $x(t_0)=x_0$, per ogni $ Delta in RR$ vale che $x(t_0+ Delta)=x_0$ allora $(x_( Delta) (t), u_( Delta) (t)) = (x(t- Delta), u(t- Delta))$ è una traiettoria. Si può dimostrare che sistemi tempo invarianti sono del tipo $ dot(x)(t) &= f (x(t), u(t)) &space x(0)=x_0 \ y(t) &= h(x(t), u(t)) $ e senza senza perdita di generalità possiamo scegliere $t_0=0$. Graficamente: #figure(image("Images/Sistemi_tempo_invarianti.png", width: 65%)) - I *sistemi lineari* sono una sotto classe di *sistemi non lineari*. I sistemi lineari sono tali se le funzioni di stato e di uscita sono lineari in $x$ e $u$: $ dot(x)_1 (t) &= a_(11) (t)x_1 (t) + a_(12) (t)x_2 (t) + . . . + a_(1n) (t)x_n (t)+ b_(11) (t)u_1 (t) + b_(12) (t)u_2 (t) + . . . + b_(1m) (t)u_m (t) \ dot(x)_2 (t) &= a_(21) (t)x_1 (t) + a_(22) (t)x_2 (t) + . . . + a_(2n) (t)x_n (t)+ b_(21) (t)u_1 (t) + b_(22) (t)u_2 (t) + . . . + b_(2m) (t)u_m (t) \ &dots.v \ dot(x)_n (t) &= a_(n 1) (t)x_1 (t) + a_(n 2) (t)x_2 (t) + . . . + a_(n n) (t)x_n (t)+ b_(n 1) (t)u_1 (t) + b_(n 2) (t)u_2 (t) + . . . + b_(n m) (t)u_m (t) $ per $y(t)$ invece $ y_1 (t) &= c_(11) (t)x_1 (t) + c_(12) (t)x_2 (t) + . . . + c_(1n) (t)x_n (t)+ d_(11) (t)u_1 (t) + d_(12) (t)u_2 (t) + . . . + d_(1m) (t)u_m (t) \ y_2 (t) &= c_(21) (t)x_1 (t) + c_(22) (t)x_2 (t) + . . . + c_(2n) (t)x_n (t)+ d_(21) (t)u_1 (t) + d_(22) (t)u_2 (t) + . . . + d_(2m) (t)u_m (t) \ &dots.v \ y_p (t) &= c_(p 1) (t)x_1 (t) + c_(p 2) (t)x_2 (t) + . . . + c_(p n) (t)x_n (t)+ d_(p 1,t)u_1 (t) + d_(p 2) (t)u_2 (t) + . . . + d_(p m) (t)u_m (t) $ == Proprietà dei sistemi lineari === Sistemi lineri in forma matriciale Definiamo le matrici $A(t) in RR^(n times n) , B(t) in RR^(n times m) , C(t) in RR^(p times n) , D(t) in RR^(p times m)$ $ A(t) &= mat(delim: "[", a_(11,t) , ... , a_(1n,t); dots.v; a_(n 1,t) , ... , a_(n n,t) ) &#h(5em) B(t) &= mat(delim: "[", b_(11,t) , ... , b_(1m,t) ; dots.v; b_(n 1,t) , ... , b_(n m,t) ) \ C(t) &= mat(delim: "[", c_(11,t) , ... , c_(1n,t) ; dots.v; c_(p 1,t) , ... , c_(p n,t) ) & D(t) &= mat(delim: "[", d_(11,t) , ... , d_(1m,t) ; dots.v; d_(p n 1,t) , ... , d_(p m,t) ) $ <matrici_sistemi_lineari> quindi scriviamo $ mat(delim: "[", dot(x)_1(t) ; dots.v; dot(x)_ n(t) ) = A(t) mat(delim: "[", x_1(t) ; dots.v; x_n (t) ) + B(t) mat(delim: "[", u_1 (t) ; dots.v; u_m (t) ) \ mat(delim: "[", y_1 (t) ; dots.v; y_n (t) ) = C(t) mat(delim: "[", x_1(t) ; dots.v; x_n (t) ) + D(t) mat(delim: "[", u_1(t) ; dots.v; u_m (t) ) $ <matrici_sistemi_lineari_2> che equivale a $ dot(x)(t) &= A(t) x(t) + B(t) u(t) \ y(t) &= C(t)x(t) + D(t) u(t) $ <sistema_lineare> == Sistemi lineari tempo-invarianti I _sistemi lineari tempo invarianti_ sono sistemi lineari in cui le matrici $A,B,C,D$ sono matrici costanti. $ dot(x)(t) = A x(t) + B u(t) \ y(t) = C x(t) + D u(t) $ <sistemi_lineari_tempo_invarianti> === Esempio carrello #figure(image("Images/Es_carrello.png", width: 40%)) $ dot(x)_1(t) &= x_2(t) &#h(5em) f_1(x,u,t) &= x_2 \ dot(x)_2(t) &= - frac(k(t),M)x_1(t) + frac(1,M) u(t) & f_2(x,u,t) &= - frac(k(t),M)x_1 + frac(1,M)u \ y(t) &= x_1(t) $ $f_2$ dipende esplicitamente da $t$ attraverso $k(t)$ quindi è un sistema tempo #underline[variante]. Se invece $k(t) = overline(k)$ (quindi una costante) per ogni $t$ allora il sistema è tempo #underline[invariante]. Siccome $f_1$ e $f_2$ dipendono linearmente da $x$ e $u$ il sistema è #underline[lineare]. $ mat(delim: "[", dot(x)_1(t) ; dot(x)_2(t) ) &= underbrace(mat(delim: "[", 0 , 1; - frac(k(t),M) , 0 ),A) mat(delim: "[", x_1(t); x_2(t) ) + underbrace(mat(delim: "[", 0 ; frac(1,M) ),B) u(t) \ y(t) &= underbrace(mat(delim: "[", 1 , 0 ),C) mat(delim: "[", x_1(t) ; x_2(t) ) + underbrace(0,D) u(t) $ per $k$ costante: $ A &= mat(delim: "[", 0 , 1 ; - frac(k,M) , 0 ) space B &= mat(delim: "[", 0; 1 ) space C &= mat(delim: "[", 1 , 0 ) $ === Sistemi lineari tempo-invarianti SISO I sistemi lineari tempo-invarianti single input single output (SISO) sono caratterizzati dalle matrici $A in RR^(n times n) , B in RR^(n times 1), C in RR^(1 times n) , D in RR^(1 times 1)$, ovvero $B$ è un vettore, $C$ è un vettore riga e $D$ è uno scalare. == Principio di sovrapposizione degli effetti Prendiamo un sistema lineare (anche tempo-variante) $ dot(x)(t) &= A(t)x(t) + B(t)u(t) \ y(t) &= C(t)x(t) + D(t)u(t) $ - sia $(x_a (t), u_a (t))$ traiettoria con $x_a (t_0)$ = $x_(0a)$ \ - sia $(x_b (t), u_b (t))$ traiettoria con $x_b (t_0)$ = $x_(0b)$ \ Allora $forall alpha, beta in RR$ dato lo stato iniziale $x_(a b,t_0) = alpha x_(0a)+ beta x_(0b)$, si ha che $ (x_(a b)(t), u_(a b)(t)) = ( alpha x_(a)(t) + beta x_b (t), alpha u_a (t)+ beta u_b (t)) $ è traiettoria del sistema, ovvero applicando come ingresso $u_(a b)= alpha u_a(t) + beta u_b(t)$ la traiettoria di stato è $x_(a b) (t) = alpha x_a (t) + beta x_b (t)$ $ cases(reverse: #true, alpha x_(0a)(t)+ beta x_(0b) (t) \ alpha u_a (t) + beta u_b (t) ) ==> alpha x_a (t) + beta x_b (t) $ <sovrapposizione_effetti> *IMPORTANTE:* non vale per i sistemi non lineari. #heading(level: 3, numbering: none)[Dimostrazione] Per dimostrarlo dobbiamo provare che soddisfa l'equazione differenziale. \ Siccome $(x_a (t), u_a (t))$ e $(x_b (t), u_b (t))$ sono traiettorie del sistema, esse soddisfano la relazione (@traiettoria_di_un_sistema) $ dot(x)_a = A(t) x_a (t) + B(t) u_a (t) \ dot(x)_b = A(t) x_b (t) + B(t) u_b (t) $ $ frac(d,d t)x_(a b,t) &= alpha dot(x)_a (t) + beta dot(x)_b (t) \ &= alpha(A(t)x_a (t) + B(t)u_a (t)) + beta (A(t)x_b (t) + B(t)u_b (t)) \ &= A(t) ( alpha x_a (t) + beta x_b (t) ) + B(t) ( alpha u_a (t) + beta u_b (t) ) $ Per sistemi lineari sotto opportune ipotesi su $A(t)$ e $B(t)$ si può dimostrare che la soluzione è unica. \ Si dimostra lo stesso anche per l'uscita. == Evoluzione libera e evoluzione forzata Sia $x_ell (t), t >= t_0$ la traiettoria di stato ottenuta per $x_ell (t_0) = x_0$ e $u_ell (t) = 0, t >= t_0$. \ Sia $x_f (t), t >= t_0$ la traiettoria di stato ottenuta per $x_f (t_0) = 0$ e $u_f (t) = u(t), t >= t_0$. Applicando il principio di sovrapposizione degli effetti si ha che, fissato lo stato iniziale $x(t_0) = x_0$ e applicando l'ingresso $u(t), t >= t_0$, la traiettoria di stato è data da $ x(t) = underbrace(x_ ell(t), "evoluzione" \ "libera") + underbrace(x_f(t), "evoluzione" \ "forzata") $<evoluzione_libera_forzata> L'*evoluzione libera* è definita come $x_ ell (t)$ per $t >= t_0$, tale che $x_ ell (t_0)=x_0$ e $u_l (t)=0$ per $t >= t_0$, e uscita $y_ ell (t)=C(t)x_ ell (t)$. L'*evoluzione forzata* è definita come $x_f (t)$ per $t >= t_0$, tale che $x_f (t_0)=0$ e $u_l (t)=u(t)$ per $t >= t_0$, e uscita $y_f (t)=C(t)x_f (t)+D(t)u(t)$. *IMPORTANTE:* non vale per i sistemi non lineari. == Traiettorie di un sistema LTI === Traiettorie di un sistema LTI: esempio scalare Definiamo un sistema lineare tempo invariante (LTI) scalare con $x in RR$, $u in RR$, $y in RR$ $ dot(x)(t) &= a x(t) + b u(t) &space x(0) &= x_0 \ y(t) &= c x(t) + d u(t) $ dall'analisi matematica possiamo scrivere il sistema come soluzione omogenea + soluzione particolare $ x(t) &= e^(a t)x_0 + integral_0^t e^(a(t- tau))b u( tau) d tau \ y(t) &= c e^(a t)x_0 + c integral_0^t e^(a(t- tau))b u( tau) d tau + d u(t) $ ricordiamo che la funzione esponenziale si può scrivere come $ e^(a t) = 1 + a t + frac((a t)^2,2!) + frac((a t)^3,3!) + ... $ === Traiettorie di un sistema LTI: caso generale Definiamo un sistema lineare tempo invariante (LTI) $x in RR^n, u in RR^m, y in RR^p$ $ dot(x)(t) &= A x(t) + B u(t) &space &x(0) = x_0 \ y(t) &= C x(t) + D u(t) $ $ underbrace(x(t),RR^n) &= underbrace(e^(A t),RR^(n times n)) underbrace(x_0,RR^n) + integral_0^t e^(A(t- tau))B u( tau) d tau \ y(t) &= C e^(a t)x_0 + c integral_0^t e^(A(t- tau))B u( tau) d tau + D u(t) $ Ricordiamo che l'esponenziale di matrice si può scrivere come $ e^(A t) = I + A t + frac((A t)^2,2!) + frac((A t)^3,3!) + ... $ $ x(t) = underbrace(e^(A t) x_0, "evoluzione" \ "libera") + underbrace(integral_0^t e^(A(t- tau))B u( tau) d tau, "evoluzione" \ "forzata") $ $ x_ ell (t) &= e^(A t)x_0 &space x_f (t) &= integral_0^t e^(A(t- tau))B u( tau) d tau $ <traiettorie_LTI> === Esempio sistema non forzato $ dot(x)_1(t) = lambda_1 x_1 (t) &wide dot(x)_2 (t) = lambda_2 x_2(t) $ $ mat(delim: "[", dot(x)_1(t); dot(x)_2(t) ) = underbrace(mat(delim: "[", lambda_1 , 0; 0 , lambda_2; ),A) mat(delim: "[", x_1(t); x_2(t) ) $ $A := Lambda$ matrice diagonale. Il nostro è un sistema non forzato, quindi c'è solo l'evoluzione libera: $ x(t) = e^(Lambda t)x_0 $ $ e^(Lambda t) &= mat(delim: "[", 1 , 0; 0, 1; ) + mat(delim: "[", lambda_1 , 0; 0 , lambda_2; ) + mat(delim: "[", lambda_1 , 0 ; 0 , lambda_2 )^2 frac(t^2,2!) + ... \ &=mat(delim: "[", 1 , 0; 0 , 1; ) + mat(delim: "[", lambda_1 , 0 ; 0 , lambda_2; ) + mat(delim: "[", frac(lambda_1^2 t^2,2!) , 0; 0 , frac( lambda_2^2 t^2,2!) ) + ... \ e^(a t) = 1 + a t + frac((a t)^2,2!) + frac((a t)^3,3!) + ... ==> quad &= mat(delim: "[", e^( lambda_1 t) , 0; 0 , e^( lambda_2 t); ) $ Quindi nel caso generale di $ Lambda in RR^(n times n)$ $ e^( Lambda t) = mat(delim: "[", e^( lambda_1 t) , 0 , ... , 0; 0 , e^( lambda_2 t) , ... , 0; dots.v, dots.v, dots.down, dots.v; 0 , 0 , ... , e^(lambda_n t) ) $ === Proprietà della matrice esponenziale <proprieta_matrice_esponenziale> Esponenziale e cambio di base: $ e^(T A T^(-1)) = T e^(A t)T^(-1) $ <matrice_esponenziale> Data una matrice $A in RR^(n times n)$, esiste $J$ matrice diagonale a blocchi, chiamata _matrice di Jordan_, che è unica a meno di permutazioni dei blocchi, tale che $ A = T^(-1) J T $ <matrice_Jordan> con $T$ matrice invertibile (matrice del cambio base). Questa formula viene chiamata _forma di Jordan_. La matrice di Jordan è fatta in questo modo #cfigure("Images/Jordan_matrix.png", 35%) con $ lambda_i$ autovalore di $A$. Utilizzando questa forma riconduco il calcolo di $e^(A t)$ al calcolo di $ e^( mat(delim: "[", lambda , 1 , 0 , ... , 0; 0 , ... , ... , ... ,0 ; ... , ... , ... , ... , 0 ; ... , ... , ... , ... , 1 ; 0 , ... , ... , 0 , lambda; ) ) = e^( lambda t) mat(delim: "[", 1 , t , frac(t^2,2!) , ...,... ; 0 , 1 , t , frac(t^2,2!) , ... ; ... , ... , ... , dots.down , ... ; 0 , ... , ... , ... , 1; ) $ (IMPORTANTE:) tutti gli elementi di $e^(A t)$ sono del tipo $ t^q e^( lambda t) $ con $q$ intero e $ lambda_i$ autovalori di A. == Rappresentazioni equivalenti Effettuiamo un cambio di base mediante una matrice $T$ $ hat(x)(t) = T x(t) $ ed essendo $T$ invertibile $ x(t) = T^(-1) hat(x)(t) $ Sostituendo nell'equazione della dinamica si ottiene $ #text(fill: purple)[$T dot$] underbrace(T^(-1) dot( hat(x))(t),dot(x)(t)) &= A underbrace(T^(-1) hat(x)(t),x(t)) + B u(t) #text(fill: purple)[$dot T$] $ $ dot(hat(x))(t) &= T A T^(-1) hat(x)(t) + T B u(t) \ y(t) &= C T^(-1) hat(x)(t) + D u(t) $ Allora chiamo $hat(A) = T A T^(-1), hat(B)=T B, hat(C) = C T^(-1), hat(D) = D$ $ dot(hat(x))(t) &= hat(A) hat(x)(t) + hat(B) u(t) \ y(t) &= hat(C) hat(x)(t) + hat(D) u(t) $ se $T$ è una matrice tale che $ J = T A T^(-1) $ allora $ dot(hat(x)) = J hat(x)(t) + T B u(t) $ L'evoluzione libera vale $ hat(x)_ ell (t) = e^(J T) hat(x)_0 $ == Modi di un sistema lineare tempo invariante Prendiamo un sistema lineare tempo invariante con $x in RR^n, u in RR^m, y in RR^p$ e $x(0)=x_0$ $ dot(x)(t) &= A x(t) + B u(t) \ y(t) &= C x(t) + D u(t) $ Indichiamo con $ lambda_1,..., lambda_r$ gli $r <= n$ autovalori (reali o complessi coniugati) distinti della matrice $A$, con molteplicità algebrica $n_1,...,n_r >= 0$ tali che $ display(sum ^r_(i=1)) n_i = n$. Le componenti dell'evoluzione libera dello stato $x_ ell (t)$ si possono scrivere come #grid(columns: (1fr, 1fr, 1fr), column-gutter: 1fr, [], math.equation(block: true ,numbering: none)[$ x_(ell, j) = sum_(i=1)^r sum_(q = 1)^h_i gamma_(j i q) t^(q-1)e^(lambda_i t) $], align(horizon)[$ j = 1,...,n $] ) per opportuni valori di $h_i <= n_i$, dove i coefficienti $ gamma_(j i q)$ dipendono dallo stato iniziale $x(0)$. I termini $t^(q-1)e^( lambda_i t)$ sono detti modi naturali del sistema. L'evoluzione libera dello stato è combinazione lineare dei modi. === Autovalori complessi Se la matrice $A$ è reale e $ lambda_i = sigma_i + j omega_i$ è un autovalore complesso, allora il suo complesso coniugato $ overline(lambda)_i = sigma_i - j omega_i$ è anch'esso autovalore di $A$. Inoltre si dimostra che i coefficienti $ gamma_(j i q)$ corrispondenti a $ lambda_i$ e $ overline(lambda)_i$ sono anch'essi complessi coniugati. Scriviamo allora l'*esponenziale di autovalori complessi coniugati*; se $ lambda_i = sigma_i + j omega_i$ e $ overline(lambda)_i = sigma_i - j omega_i$ allora $ e^( lambda_i t) &= e^( sigma_i + j omega_i) &space e^( overline( lambda)_i t) &= e^( sigma_i - j omega_i) \ &= e^( sigma_i t) e^(j omega_i t) & &= e^( sigma_i t) e^(-j omega_i t) \ &= e^( sigma_i t) ( cos( omega_i t) + j sin( omega_i t)) & &= e^( sigma_i t) ( cos( omega_i t) - j sin( omega_i t)) $ Si verifica quindi, per calcolo diretto, che le soluzioni $x_(ell,j)(t)$ sono sempre reali e che i modi del sistema corrispondenti ad autovalori complessi coniugati $ lambda_i$ e $ overline( lambda)_i$ sono del tipo $ t^(q-1) e^( sigma_i t) cos ( omega_i t + phi_i) $ con opportuni valori della fase $ phi_i$. Supponiamo che le molteplicità algebriche $n_1,...,n_r$ degli autovalori di $A$ coincidano cone le molteplicità geometriche (ad esempio quando gli autovalori sono distinti). Allora i coefficienti $h_i$ sono tutti pari a 1 e l'espressione dei modi si semplifica in $ &e^( lambda_i t) &space &"per autovalori reali" \ &e^( sigma _i t) cos ( omega_i t + phi_i) & & "per autovalori complessi coniugati" $<autovalori_complessi> === Modi naturali: autovalori reali semplici <Modi_naturali_autovalori_reali_semplici> #cfigure("Images/Autovalori_semplici.png", 70%) === Modi naturali: autovalori complessi coniugati semplici #cfigure("Images/Autovalori_complessi.png", 70%) #cfigure("Images/Esempio_autovalori.png", 70%) === Esempio sui modi naturali $ mat(delim: "[", dot(x)_1; dot(x)_2 ) = mat(delim: "[", 0 , 1; a^2 , 0; ) mat(delim: "[", x_1 ; x_2 ) $ $ p( lambda) &= det ( lambda I -A) \ &= lambda^2 - a^2 \ & => cases( lambda_1 = a\ lambda_2 = -a ) $ I modi naturali di questo sistema sono $ &e^(a t) &space space &e^(-a t) $ Il modo $e^(a t)$ diverge a infinito, il che non è una cosa "buona" per dei sistemi di controllo, perché ad esempio se si sta realizzando un sistema di controllo della velocità vuol dire che la mia velocità sta aumentando, mentre dovrebbe rimanere fissa in un range. Non bisogna quindi focalizzarsi sul calcolare con precisione il valore dei modi naturali ma è importante conoscere come si comporta la loro parte reale. === Esempio 1 Consideriamo il seguente sistema LTI con $x in RR^3$ e $u in RR^3$ $ dot(x)(t) = underbrace(mat(delim: "[", 0 , 1 , -1 ; 1 , -1 , -1 ; 2 , 1 , 3 ),A) x(t) + underbrace(mat(delim: "[", 1 , 1 , 0 ; 0 , 1 , 1 ; 1 , 1 , 1 ),B) u(t) $ Mediante un cambio di coordinate usando la matrice $T = mat(delim: "[", 0 , -1 , 1 ; 1 , 1 , -1 ; -1 , 0 , 1 )$ e ponendo $ hat(x)(t) = T x(T)$, il sistema si può riformulare come $ hat(dot(x)) (t)= underbrace(mat(delim: "[", -1 , 1 , 0; 0 , -1 , 0; 0 , 0 , -2 ), hat(A) = T A T^(-1)) hat(x)(t) + underbrace(mat(delim: "[", 1 , 0 , 0; 0 , 1 , 0; 0 , 0 , 1 ), hat(B) = T B) u(t) $ Gli autovalori di $hat(A)$ sono $-1, -2$ con molteplicità algebrica $2,1$. Per calcolare l'evoluzione libera consideriamo la formula vista in precedenza $ hat(x)_ ell =e^(hat(A) t) hat(x)_0 $ Calcoliamo quindi l'esponenziale di matrice $e^( hat(A) t)$ per $ hat(A) = mat(delim: "[", -1 , 1 , 0; 0 , -1 , 0; 0 , 0 , -2 )$ $ e^( hat(A) t) &= sum_(k=0)^ infinity mat(delim: "[", -1 , 1 , 0; 0 , -1 , 0; 0 , 0 , -2 )^k frac(t^k,k!) \ &= mat(delim: "[", display(sum_(k=0)^ infinity) frac((-1)^k t^k,k!) , t display(sum _(k=0)^ infinity) frac((-1)^k t^k,k!) , 0; 0 , display(sum_(k=0)^ infinity) frac((-1)^k t^k,k!) , 0; 0 , 0 , display(sum_(k=0)^ infinity) frac((-2)^k t^k,k!) ) \ &= mat(delim: "[", e^(-t) , t e^(-t) , 0; 0 , e^(-t) , 0; 0 , 0 , e^(-2t) ) $ quindi l'evoluzione libera dello stato è $ hat(x)_ ell = mat(delim: "[", e^(-t) , t e^(-t) , 0; 0 , e^(-t) , 0; 0 , 0 , e^(-2t); ) hat(x)_0 $ - Se ad esempio la condizione iniziale è $ hat(x)_0 = mat(delim: "[", 1 ; 0 ; 0 )$, allora $ hat(x)_ ell = mat(delim: "[", e^(-t) ; 0 ; 0 ) $ Scriviamolo nello coordinate originali $ x_ell(t) = underbrace(mat(delim: "[", 1,1,0; 0,1,1; 1,1,1; ),T^(-1)) hat(x)_ ell (t) = mat(delim: "[", e^(-t); 0; e^(-t) ) $ - Se prendiamo come condizione iniziale $ hat(x)_0 = mat(delim: "[", 0 ; 1; 0 )$, allora $ hat(x)_ ell = mat(delim: "[", t e^(-t) ; e^(-t) ; 0 ) $ Scriviamolo nello coordinate originali $ x_ ell(t) = underbrace(mat(delim: "[", 1,1,0; 0,1,1; 1,1,1 ) ,T^(-1)) hat(x)_ ell (t) = mat(delim: "[", e^(-t) + t e^(-t); e^(-t); e^(-t) + t e^(-t) ) $ - Se prendiamo come condizione iniziale $ hat(x)_0 = mat(delim: "[", 0 ; 0 ; 1 )$. allora $ hat(x)_ ell = mat(delim: "[", 0 ; 0 ; e^(-2t) ) $ Nelle coordinate originali: $ x_ ell(t) = underbrace(mat(delim: "[", 1,1,0; 0,1,1; 1,1,1 ) ,T^(-1)) hat(x)_ ell (t) = mat(delim: "[", 0; e^(-2t); e^(-2t) ) $ === Esempio carrello $ dot(x)_1(t) &= x_2(t) \ dot(x)_2(t) &= - frac(k(t),M)x_1(t) + frac(1,M) u(t) \ y(t) &= x_1(t) $ $ mat(delim: "[", dot(x)_1(t) ; dot(x)_2(t) ) &= mat(delim: "[", 0 , 1 ; - frac(k,M) , 0 ) mat(delim: "[", x_1(t); x_2(t) ) + mat(delim: "[", 0; frac(1,M) ) u(t) \ y(t) &= mat(delim: "[", 1 , 0 ) mat(delim: "[", x_1(t); x_2(t) ) + 0 u(t) $ Consideriamo $k$ costante, quindi sistema LTI. Gli autovalori della matrice $A$ sono $ lambda_1 = j sqrt(dfrac(k,M)), lambda_2 = -j sqrt(dfrac(k,M))$ immaginari puri. Applichiamo un controllo $u = - h x_2$. Le equazioni di stato del sistema diventano: $ dot(x)_1(t) &= x_2(t)\ dot(x)_2(t) &= - frac(k,M)x_1(t) - frac(h,M)x_2(t) $ in forma matriciale $ mat(delim: "[", dot(x)_1(t); dot(x)_2(t) ) &= mat(delim: "[", 0 , 1; - frac(k,M) , - frac(h,M) ) mat(delim: "[", x_1(t); x_2(t) ) $ Quindi calcoliamo gli autovalori della matrice //This command set all gaps in the matrices in the element with <big_matrices> label to 1em //#show <big_matrices>: set math.mat(gap: 1em) $ A &= mat(delim: "[", 0 , 1; - frac(k,M) , - frac(h,M) ) &space space A - lambda I &= mat(delim: "[", - lambda , 1; - frac(k,M) , - frac(h,M) - lambda ) $ calcolando il determinante e ponendolo a zero si trova il polinomio caratteristico associato a essa $ & &space lambda_1 &= - frac(h,2M) + sqrt( frac(h^2,4M^2) - frac(k,M)) \ p( lambda) &= lambda^2 + lambda frac(h,M) + frac(k,M) ==> \ & & lambda_2 &= - frac(h,2M) - sqrt( frac(h^2,4M^2) - frac(k,M)) $ le cui soluzioni sono gli autovalori della matrice A. Prendiamo ora in considerazione la quantità sotto radice; è evidente che se $h^2 > 4 M k$ gli autovalori sono reali, mentre se $h^2 < 4 M k$ sono complessi coniugati. Se invece $h^2 = 4 M k$, $ lambda_1 = lambda_2 = - frac(h,2M)$, con molteplicità algebrica pari a 2. Si può dimostrare che la molteplicità geometrica è pari a 1, quindi il blocco di Jordan sarà $2 times 2$ (guardare @proprieta_matrice_esponenziale) //#show <big_matrices>: set math.mat(delim: "[", gap: 2em) $ J &= T A T^(-1) = mat(delim: "[", - frac(h,2M) , 1; 0 , - frac(h,2M) ) &space space e^(J t) &= e^(- frac(h,2M)t) mat(delim: "[", 1 , t; 0 , 1 ) $ $ hat(x)_ ell = mat(delim: "[", e^(- frac(h,2M)t) hat(x)_1(0) + t e^(- frac(h,2M)t) hat(x)_2(0); e^(- frac(h,2M)t) hat(x)_2(0) ) = mat(delim: "[", hat(x)_(1 ell)(t); hat(x)_(2 ell)(t) ) $ Quindi i modi naturali del sistema sono $ &e^(- frac(h,2M)t) &space space &t e^(- frac(h,2M)t) $ da notare che anche si effettua il cambio di coordinate i modi del sistema non cambiano. - Supponiamo $ hat(x)(0) = mat(delim: "[", 1 ; 0 )$, allora $ hat(x)_ ell (t) = mat(delim: "[", e^(- frac(h,2M)t) hat(x)_1(0); 0 ) $ - Supponiamo $ hat(x)(0) = mat(delim: "[", 0 ; 1 )$, allora $ hat(x)_ ell (t) = mat(delim: "[", 0 ; e^(- frac(h,2M)t) hat(x)_2(0) ) $ #align(center)[ #cetz.canvas({ import cetz.draw: * content((2, 4.2), [$y=t e^(- frac(h,2M)t)$], name: "text") plot.plot( size: (7,4), x-tick-step: none, y-tick-step: none, axis-style: "left", plot-style: plot.palette.rainbow, { plot.add( domain: (0, 20), x => calc.sin(x * calc.pow(calc.e,-2/4 * x))) } ) })] Si nota dal grafico che se $- dfrac(h,2M)$ è "grande" il modo va a zero, quindi sono in un punto di equilibrio. - Se $h = 4M k = 0$ con $M >0,h=0,k=0$, il sistema diventa $ mat(delim: "[", dot(x)_1(t); dot(x)_2(t) ) = mat(delim: "[", 0 , 1; 0 , 0; ) mat(delim: "[", x_1(t); x_2(t) ) $ i cui modi naturali sono $1,t$. È evidente che queste equazioni differenziali si possono scrivere come combinazione lineare dei modi: $ x_1(t) &= x_1(0) + x_2(0)t\ x_2(t) &= x_2(0) $ == Stabilità interna === Richiami sull'equilibrio di un sistema Prendiamo un sistema lineare tempo invariante $ dot(x)(t) = f(x(t), u(t)) $ Poniamo $u(t) = u_e forall t >= 0$, allora #tageq($dot(x)(t) = f(x(t), u_e)$, $x(0)=x_0$) Esiste, per un sistema di questo tipo, una $x_e$ tale che se $x(0)=x_e ==> x(t) = x_e forall t >= 0$, quindi tale che se lo stato iniziale è costante la $x(t)$ rimane costante in ogni istante di tempo? Chiamo $x_e$ equilibrio, $(x_e,u_e)$ la chiamo coppia stato-ingresso di equilibrio. Proprietà fondamentale di una coppia di equilibrio è che $ f(x_e,u_e) = 0 $ === Definizione generale Per sistemi tempo-invarianti (anche se si può generalizzare) la _stabilità interna_ di un sistema è l'insieme delle conseguenze sulla traiettoria legate a incertezze sullo stato iniziale con ingressi fissi e noti. === Stabilità interna per sistemi non forzati <Stabilità_interna> #tageq($dot(x)(t) = f(x(t))$, $x_e "equilibrio"$) *Equilibrio stabile:* uno stato di equilibrio $x_e$ si dice stabile se $ forall epsilon >0, exists delta >0$ tale che $ forall x_0 : || x_0-x_e || <= delta$ allora risulti $ || x(t) - x_e || < epsilon med forall t >= 0$. *Equilibrio instabile:* uno stato di equilibrio $x_e$ si dice instabile se non è stabile. *Equilibrio attrattivo:* uno stato di equilibrio $x_e$ si dice attrattivo se $ exists delta$ tale che $ forall x_0: || x_0-x_e || <= delta$ allora risulti $ display(lim_(t arrow infinity)) || x(t)-x_e ||=0$; quindi se il sistema è in equilibrio solo a infinito. *Equilibrio asintoticamente stabile:* uno stato di equilibrio $x_e$ si dice asintoticamente stabile se è stabile e attrattivo. *Equilibrio marginalmente stabile:* uno stato di equilibrio si dice marginalmente stabile se è stabile ma non asintoticamente. #figure( image("Images/Equilibrio_stabile.png", width: 55%), caption: [Rappresentazione grafica di un sistema in equilibrio stabile] ) #figure( image("Images/Equilibrio_attrattivo.png", width: 55%), caption: [Rappresentazione grafica di un sistema in equilibrio attrattivo] ) *N.B.* $delta < epsilon$. === Osservazioni Le definizioni date sottintendono la parola locale, ovvero che la proprietà vale in un intorno dello stato di equilibrio $x_e$. *Stabilità globale:* le proprietà di stabilità e asintotica stabilità sono globali se valgono per ogni $x in RR^n$, invece che valere solo per $x_0$. *Stabilità di una traiettoria:* le definizioni di stabilità si possono generalizzare a una traiettoria $ overline(x)(t), t >= 0$. #cfigure("Images/Stabilita_traiettoria.png", 70%) == Stabilità interna di sistemi LTI Nei sistemi lineari $x=0$ è sempre un equilibrio. Per sistemi lineari si può dimostrare che tutti gli equilibri e tutte le traiettorie hanno le stesse proprietà di stabilità, tutte uguali a $x=0$. Per questo motivo si parla di *stabilità del sistema*. #heading(level: 3, numbering: none)[Dimostrazione] Sappiamo che $ dot(x)(t) =& A x(t) + B u(t) \ A x_e +& B u_e = 0 $ allora supponiamo che $ u(t) = u_e wide forall t >= 0 $ Sia $ tilde(x)(t) := x(t) - x_e$, allora $ dot(tilde(x))(t) &= dot(x)(t) - underbrace( frac(d,d t)x_e,0) \ &=A x(t)+B u_e \ &=A( tilde(x)(t)+x_e)+B u_e \ &=A tilde(x)(t) + underbrace(A x_e+B u_e,0) $ quindi $ dot(tilde(x))(t) = A tilde(x)(t) $ Concludiamo che $ dot(tilde(x))(t) = A tilde(x)(t) = 0 <==> tilde(x)=0 <==> x = x_e $ cioè per studiare l'equilibrio di un sistema nel generico punto $x_e$ posso studiare l'equilibrio del sistema nell'origine. === Teorema <Teorema_parte_reale_negativa> Un sistema LTI è *asintoticamente stabile* #underline[se e solo se] tutti gli autovalori della matrice della dinamica hanno parte reale strettamente negativa. *N.B.* Se gli autovalori della matrice della dinamica hanno parte reale strettamente negativa i modi del sistema tendono a 0 (vedi @Modi_naturali_autovalori_reali_semplici[modi naturali di autovalori semplici]) === Teorema Un sistema LTI è stabile se e solo se tutti gli autovalori della matrice della dinamica hanno parte reale minore o uguale a zero e tutti gli autovalori a parte reale nulla hanno molteplicità geometrica uguale alla molteplicità algebrica (i mini blocchi di Jordan associati hanno dimensione uno). #heading(level: 3, numbering: none)[Osservazione] Si ha instabilità se almeno un autovalore della matrice della dinamica ha parte reale positiva o se almeno un autovalore con parte reale nulla ha molteplicità algebrica maggiore della molteplicità geometrica. #heading(level: 3, numbering: none)[Osservazione] La stabilità asintotica di sistemi LTI è sempre globale #grid(columns: (1fr, 1fr, 1fr), column-gutter: 1fr, row-gutter: 4pt, [], math.equation(block: true ,numbering: none)[$x(0) &= x_0 ==> x(t)$], align(horizon)[$t >= 0 $], [], math.equation(block: true ,numbering: none)[$x(0) &= alpha x_0 ==> alpha x(t)$], align(horizon)[$t >= 0 $] ) #heading(level: 3, numbering: none)[Proprietà] Se un sistema LTI è globalmente asintoticamente stabile, $x=0$ è l'unico equilibrio. \ *Nota:* anche per sistemi #underline[non lineari] se $x_e$ è GAS (Globalmente Asintoticamente Stabile) allora è l'unico equilibrio. //Questo perché RIVEDI === Esempio stabilità del sistema carrello $ dot(x)_1(t) &= x_2(t) \ dot(x)_2(t) &= - frac(k(t),M)x_1(t) + frac(1,M) u(t) y(t) &= x_1(t) $ $ mat(delim: "[", dot(x)_1(t); dot(x)_2(t) ) &= mat(delim: "[", 0 , 1; - frac(k,M) , 0 ) mat(delim: "[", x_1(t); x_2(t) ) + mat(delim: "[", 0; frac(1,M) ) u(t) \ y(t) &= mat(delim: "[", 1 , 0 ) mat(delim: "[", x_1(t); x_2(t); ) + 0 u(t) $ Consideriamo $k$ costante, quindi sistema LTI. Gli autovalori della matrice $A$ sono $ lambda_1 = j sqrt( dfrac(k,M)), lambda_2 = -j sqrt( dfrac(k,M))$ immaginari puri, quindi sistema semplicemente (marginalmente) stabile. Se applichiamo $u=-h x_2$ gli autovalori diventano $ lambda_1 = - dfrac(h,2M) + sqrt( dfrac(h^2,4M^2)- dfrac(k,M))$ e $ lambda_2 = dfrac(h,2M) - sqrt( dfrac(h^2,4M^2)- dfrac(k,M))$. - Se $h^2 >= 4M k$ gli autovalori sono 2 reali negativi, quindi il sistema è asintoticamente stabile; - Se $h^2 < 4M k$ gli autovalori sono 2 complessi coniugati con parte reale negativa, quindi il sistema è asintoticamente stabile; - Se $h^2 = 4M k$, $ lambda_1 = lambda_2 = - dfrac(h,2M)$, con molteplicità algebrica pari a 2. Si può dimostrare che la molteplicità geometrica è pari a 1, quindi il blocco di Jordan sarà $2 times 2$ (guardare le @proprieta_matrice_esponenziale[proprietà della matrice esponenziale]) $ J &= T A T^(-1) = mat(delim: "[", - frac(h,2M) , 1; 0 , - frac(h,2M) ) &space space e^(J t) &= e^(-frac(h,2M)t) mat(delim: "[", 1 , t; 0 , 1 ) $ #h(0.8em)Gli autovalori sono a parte reale negativa, quindi il sistema è asintoticamente stabile; - Se $h=k=0 ==> lambda_1= lambda_2=0$, quindi il sistema è instabile. == Retroazione dello stato Prendiamo un sistema lineare tempo invariante $ dot(x)(t) &= A x(t) + B u(t)\ y(t) &= C x(t) + D u(t) $ Supponendo di misurare l'intero stato, ovvero se $x(t)=y(t)$, allora possiamo progettare $ u(t) = K x(t) + v(t) $ con $K in RR^(m times n)$ una matrice di guadagni e $v(t)$ un ulteriore ingresso per il sistema retroazionato $ dot(x)(t) = (A+B K)x(t)+B v(t) $ Se vogliamo il sistema in anello chiuso asintoticamente stabile allora dobbiamo progettare $K$ tale che $(A + B K)$ abbia autovalori tutti a parte reale negativa.\ *Nota:* la possibilità di scegliere gli autovalori di $(A + B K)$ (e.g., per renderli tutti a parte reale negativa) dipende dalla coppia $(A, B)$ ed è legata alla proprietà di *raggiungibilità*. Se non è possibile misurare l'intero stato, ovvero se $y(t) != x(t)$, esistono tecniche per ricostruire lo stato a partire dalle misure mediante sistemi ausiliari chiamati *osservatori*. Se sia possibile o meno ricostruire lo stato dipende dalla coppia $(A, C)$ ed è legato alla proprietà di *osservabilità*. === Proprietà di raggiungibilità (facoltativo) Uno stato $tilde(x)$ si un sistema LTI si dice _raggiungibile_ se esistono un istante di tempo finito $tilde(t)>0$ e un ingresso $tilde(u)$, definito tra 0 e $tilde(t)$, tali che, detto $tilde(x)_f (t)$, $0<=t<=tilde(t)$, il movimento forzato dello stato generato da $tilde(u)$, risulti $tilde(x)_f (t) = tilde(x)$. Un sistema i cui stati siano tutti raggiungibili si _completamente raggiungibile_. Quindi, un particolare vettore $tilde(x)$ costituisce uno stato raggiungibile se è possibile, con un'opportuna scelta dell'ingresso, trasferire dall'origine al vettore in questione lo stato del sistema. #heading(level: 3, numbering: none)[Teorema] Detta $M_r$ _matrice di raggiungibilità_ definita come $ M_r = [B thin A B thin A^2 B thin dots thin A^(n-1) B ] in RR^(n times m n) $ un sistema LTI è completamente raggiungibile, ovvero la coppia $(A,B)$ è completamente raggiungibile, se e solo se il rango della matrice di raggiungibilità è pari a $n$, cioè $ rho (M_r) = n $ === Proprietà di osservabilità (facoltativo) Uno stato $tilde(x) != 0$ di un sistema LTI si dice _non osservabile_ se, qualunque sia $tilde(t) > 0$ finito, detto $tilde(y)_ell (t), t >= 0$, il movimento libero dell'uscita generato da $tilde(x)$ risulta $tilde(y)_ell (t) = 0, 0<=t<=tilde(t)$. Un sistema privo di stati non osservabili si dice _completamente osservabile_. Quindi, un particolare vettore $tilde(x)$ costituisce uno stato non osservabile se l'esame di un tratto di qualunque durata del movimento libero dell'uscita da esso generata non consente di distinguerlo dal vettore $x=0$. #heading(level: 3, numbering: none)[Teorema] Detta $M_o$ _matrice di osservabilità_, definita come $ M_o = [C^T thin A^T C^T thin A^T^2 C^T thin dots thin A^T^(n-1)C^T] in RR^(n times p n) $ un sistema LTi è completamente osservabile, ovvero la coppia $(A,C)$ è completamente osservabile, se e solo se il rango della matrice di osservabilità è pari a $n$, cioè $ rho (M_o) = n $ == Linearizzazione di sistemi in non lineari (tempo invarianti) Prendiamo un sistema non lineare tempo invariante $ dot(x)(t) &= f (x(t), u(t))\ y(t) &= h(x(t), u(t)) $ Sia $(x_e,u_e)$ una coppia di equilibrio, $f(x_e,u_e)=0$, consideriamo una traiettoria a partire da uno stato stato iniziale $x(0)=x_e+ tilde(x)_0$ $ x(t) &= x_e + tilde(x)(t)\ u(t) &= u_e + tilde(u)(t) $ con $y(t) = h(x_e , u_e ) + tilde(y)(t) = y_e + tilde(y)(t)$. Essendo una traiettoria vale $ frac(d,d t)(x_e + tilde(x)(t)) &= f (x_e + tilde(x)(t), u_e + tilde(u)(t))\ y_e + tilde(y)(t) &= h(x_e+ tilde(x)(t), u_e+ tilde(u)(t)) $ Sviluppando in serie di Taylor (con $f$ e $h$ sufficientemente regolari) in $(x e , u e)$ #footnote[i termini del tipo $ frac(diff, diff x)f(x,u)$ vengono chiamati _Jacobiani_] $ frac(d,d t)(x_e + tilde(x)(t)) &= underbrace(f(x_e,u_e),0) + underbrace(lr(frac(diff, diff x)f(x,u) |) _(x=x_e \ u=u_e),A_e) tilde(x)(t) + underbrace(lr(frac(diff, diff u)f(x,u)|)_(x=x_e \ u=u_e),B_e) tilde(u)(t) + "term. ord. sup." \ y_e+ tilde(y)(t) &= h(x_e,u_e) + underbrace(lr(frac( diff, diff x)h(x,u)|)_(x=x_e \ u=u_e),C_e) tilde(x)(t) + underbrace(lr(frac(diff, diff u)h(x,u)|)_(x=x_e \ u=u_e),D_e) tilde(u)(t) + "term. ord. sup." $ $ A &= lr(frac(diff f(x,u), diff x)|)_(x=x_e \ u=u_e) &space space B &= lr(frac( diff f(x,u), diff u)|)_(x=x_e \ u=u_e) \ C &= lr(frac( diff g(x,u), diff x)|)_(x=x_e \ u=u_e) & D &= lr(frac( diff g(x,u), diff u)|)_(x=x_e \ u=u_e) $ quindi #grid(columns: (1fr, 1fr, 1fr), column-gutter: 1fr, row-gutter: 4pt, [], math.equation(block: true ,numbering: none)[$tilde(dot(x))(t) &= A_e tilde(x)(t) + B_e tilde(u)(t) + "term. ord. sup."$], align(horizon)[$tilde(x)(0) = tilde(x)_0$], [], math.equation(block: true ,numbering: none)[$tilde(y)(t) &= C_e tilde(x)(t) + D_e tilde(u)(t) + "term. ord. sup."$], align(horizon)[] ) Se consideriamo i termini di ordine superiore come un resto $ cal(R) (x,u)$ si osserva che $ lim_(||(tilde(x),tilde(u))|| arrow 0) frac(||cal(R)( tilde(x), tilde(u))||, ||( tilde(x), tilde(u))||) = 0 $ di fatto è come se si avesse $ display(lim_(x arrow 0)) dfrac(x^2,x)$. Quindi le due equazioni di prima si possono approssimare $ tilde(dot(x))(t) & approx A_e tilde(x)(t) + B_e tilde(u)(t)\ tilde(y)(t) & approx C_e tilde(x)(t) + D_e tilde(u)(t) $ Il sistema linearizzato è $ Delta dot(x)(t) &= A_e Delta x(t) + B_e Delta u(t)\ Delta y(t) &= C_e Delta x(t) + D_e Delta u(t) $ *N.B.* il pedice 'e' è una puntualizzazione ulteriore per sottolineare il fatto che le matrici sono valutate all'equilibrio, in altri testi potrebbero non avere questo pedice. Le traiettorie del sistema non lineare soddisfano $ x(t) &= x_e + tilde(x)(t) &&approx x_e + Delta x(t)\ u(t) &= u_e + tilde(u)(t) &&approx u_e + Delta u(t)\ y(t) &= y_e + Delta y(t) &&approx y_e + Delta y(t) $ per variazioni sufficientemente piccole. *Nota:* $( Delta x(t), Delta u(t)), t >= 0$ traiettoria del sistema linearizzato. === Esempio pendolo $ dot(x)_1(t) &= x_2(t) &&= f_1(x(t),u(t))\ dot(x)_2(t) &= -frac(g,l) sin(x_1(t)) -frac(b,M ell^2)x_2(t)+frac(1,M ell^2) u(t) &&= f_2(x(t),u(t)) $ $(x_e,u_e)$ coppia di equilibrio $ f(x_e,u_e)=0 arrow cases( x_(2e)=0\ - dfrac(g, ell) sin(x_(1e)) - dfrac(b,M ell^2)x_(2e) + dfrac(1,M ell^2)u_e ) $ Prendiamo come equilibrio $x_e = mat(delim: "[", x_(1e); 0 )$, allora $ &- dfrac(g, ell) sin(x_(1e)) - dfrac(b,M ell^2) dot 0 + dfrac(1,M ell^2)u_e = 0\ ==> & u_e = g M ell sin(x_(1e)) $ Eseguiamo la linearizzazione intorno a $(x_e,u_e)$ $ Delta dot(x)(t) = A_e Delta x(t) + B_e Delta u(t) $ $ underbrace(A_e, frac( diff f(x,u), diff x)|_(x=x_e \ u=u_e)) &= mat(delim: "[", dfrac(diff f_1(x,u), diff x_1) , dfrac( diff f_1(x,u), diff x_2); dfrac( diff f_2(x,u), diff x_1) , dfrac( diff f_2(x,u), diff x_2); )_(x=x_e \ u=u_e) &space space underbrace(B_e, frac(diff f(x,u), diff u)|_(x=x_e \ u=u_e)) &= mat(delim: "[", dfrac(diff f_1(x,u), diff u); dfrac(diff f_2(x,u),diff u) ) \ &= mat(delim: "[", 0 , 1; - dfrac(g, ell) cos(x_1) , - dfrac(b,M ell^2) )_(x=x_e \ u=u_e) & &= mat(delim: "[", 0; dfrac(1,M ell^2) )_(x=x_e \ u=u_e) \ &= mat(delim: "[", 0 , 1; - dfrac(g, ell) cos(x_(1e)) , - dfrac(b,M ell^2) ) & &= mat(delim: "[", 0; dfrac(1,M ell^2) ) $ - se $x_e = mat(delim: "[", 0 ; 0 )$ e $u_e = 0$ $ A_e &= mat(delim: "[", 0 , 1 ; - dfrac(g, ell) , - dfrac(b,M ell^2) ) &space B_e &= mat(delim: "[", 0; dfrac(1,M ell^2) ) $ - se $x_e=mat(delim: "[", pi ; 0 )$ e $u_e=0$ $ A_e &= mat(delim: "[", 0 , 1; dfrac(g, ell) , - dfrac(b,M ell^2) ) &space B_e &= mat(delim: "[", 0; dfrac(1,M ell^2) ) $ - se $x_e=mat(delim: "[", pi/2 ; 0 )$ e $u_e=M G ell$ $ A_e &= mat(delim: "[", 0 , 1; 0 , - dfrac(b,M ell^2) ) &space B_e &= mat(delim: "[", 0; dfrac(1,M ell^2) ) $ === Stabilità di 3 sistemi lineari (linearizzazione intorno a 3 diversi equilibri) #v(2em) #enum()[ Se $x_e = mat(delim: "[", 0 ; 0 )$ e $u_e = 0$ $ A_e &= mat(delim: "[", 0,1; -dfrac(g, ell), - dfrac(b,M ell^2) ) &space p( lambda) &= lambda ( lambda + frac(b,M ell^2)) + frac(g, ell)\ & & &= lambda^2 + frac(b,M ell^2) lambda + frac(g, ell) $ $ lambda_(1 slash 2) = -frac(b,2M ell^2) plus.minus sqrt( ( frac(b,2M ell^2) ) - frac(g, ell)) $ Abbiamo 2 autovalori a parte reale negativa, quindi il sistema linearizzato è _asintoticamente stabile globalmente_. #v(2em) ][ Se $x_e=mat(delim: "[", pi ; 0 )$ e $u_e=0$ $ A_e &= mat(delim: "[", 0,1; dfrac(g, ell), - dfrac(b,M ell^2) ) &space p( lambda) &= lambda ( lambda + frac(b,M ell^2) ) - frac(g, ell)\ & & &= lambda^2 + frac(b,M ell^2) lambda - frac(g, ell) $ $ lambda_(1 slash 2) = - frac(b,2M ell^2) plus.minus sqrt( underbrace( ( frac(b,2M ell^2) ) + frac(g, ell), >0)) ==> cases( lambda_(1) = - dfrac(b,2M ell^2) - sqrt( ( dfrac(b,2M ell^2) ) + dfrac(g, ell)) quad<0 \ lambda_(2) = - dfrac(b,2M ell^2) + sqrt( ( dfrac(b,2M ell^2) ) + dfrac(g, ell)) quad>0 ) $ Dato che abbiamo un autovalore a parte reale positiva il sistema è _instabile_. #v(2em) ][ Se poniamo $x_e = mat(delim: "[", pi/2 ; 0 )$ e $u_e = M g ell$ $ A_e &= mat(delim: "[", 0, 1; 0, - dfrac(b,M ell^2) ) &space p( lambda) &= lambda ( lambda + frac(b, M ell^2) ) $ $ lambda_1 &= 0 &space space lambda_2&=- frac(b,M ell^2) $ Il sistema linearizzato è _stabile_, ma non asintoticamente, cioè marginalmente stabile (ricordando il @Teorema_parte_reale_negativa[Teorema]) ] == Stabilità e linearizzazione === Teorema Dato un sistema non lineare tempo invariante, $dot(x)(t)=f(x(t),u(t))$, sia $x_e,u_e$ una coppia di equilibrio. Se il sistema linearizzato intorno a $(x_e,u_e)$ è asintoticamente stabile, allora l'equilibrio $x_e$, relativo all'ingresso $u_e$, è #underline[(localmente) asintoticamente stabile]. === Teorema Dato un sistema non lineare tempo invariante, $dot(x)(t)=f(x(t),u(t))$, sia $x_e,u_e$ una coppia di equilibrio. Se il sistema linearizzato intorno a $(x_e,u_e)$ ha almeno un autovalore a parte reale positiva, allora l'equilibrio $x_e$, relativo all'ingresso $u_e$, è #underline[instabile]. === Controllo non lineare mediante linearizzazione Consideriamo il sistema non lineare $ dot(x)(t) = f(x(t),u(t)) $ Linearizzazione intorno all'equilibrio $(x_e,u_e)$ $ Delta dot(x)(t) = A Delta x(t) + B Delta u(t) $ Proviamo a portare $ Delta x(t)$ a 0, ovvero $x(t)$ a $x_e$ "in modo approssimato". Usando la retroazione dello stato $ Delta u(t) = K Delta x(t) + Delta v(t)$ otteniamo il seguente sistema in anello chiuso $ Delta dot(x)(t) = (A_e + B_e K) Delta x(t) + B_e Delta v(t) $ Così sono in grado di progettare la matrice $K$ in modo che $A_e + B_e K$ sia asintoticamente stabile. Grazie ai teoremi sulla linearizzazione, $x_e$ risulta un equilibrio (localmente) asintoticamente stabile per il sistema non lineare in anello chiuso (detto _retroazionato_). Visto che $ Delta x(t) approx x(t) - x_e$ $ u(t) = u_e + K(x(t) - x_e) + tilde(v)(t) approx u_e + K Delta x(t) + tilde(v)(t) $ Perciò la legge di controllo finale sarà $ u(t) = u_e + K(x(t)-x_e) + tilde(v)(t) $ #cfigure("Images/Controllo_retroazionato.png", 67%) = Trasformata di Laplace == Definizione Data una funzione complessa $f$ di variabile reale $t$, $f: RR arrow CC$ (anche se per noi tipicamente saranno funzioni $f: RR arrow RR$), sia $s = sigma + j omega$ una variabile complessa ($ sigma$ parte reale, $ omega$ parte immaginaria); definiamo la _Trasformata di Laplace_ di $f(t)$ $ F(s) = integral_(0^-)^(+ infinity) f(t) e^(-s t) d t $ se esiste per qualche $s$, ovvero se l'integrale converge. Includiamo nell'integrale $0^(-)$ per tener conto di eventuali impulsi cone la _delta di Dirac_. *Notazione:* indichiamo la trasformata di Laplace con $ cal(L)$ tale che $ f(t) xarrow(width: #3em, #text(size: 10pt)[$cal(L)$] ) F(s) $ con $F: CC arrow CC$; indichiamo l'applicazione della trasformata con $F(s) = cal(L)[f(t)]$. == Osservazioni === Ascissa di convergenza Sia $ overline( sigma)>- infinity$ estremo inferiore di $s= sigma + j omega$ per cui l'integrale converge. Allora la trasformata di Laplace esiste nel semipiano $ Re (s)> overline( sigma)$. \ $ overline( sigma)$ viene chiamata _ascissa di convergenza_. La trasformata di Laplace risulta essere una _funzione analitica_ e, grazie alle particolari proprietà delle funzioni analitiche, la sua definizione può essere estesa anche in punti di $s$ tali che $ Re(s) <= overline(sigma)$, indipendentemente dal fatto che l'integrale non converga. Dato che $ e^(-s t) = e^(- sigma t)e^(-j omega t) $ possiamo dire che $e^(- sigma t)$ ci aiuta a ottenere un integrale che converge. #align(center)[ #cetz.canvas({ import cetz.draw: * content((0.8, 3.5), [$e^(- sigma t)$], name: "text") plot.plot( size: (6,4), x-tick-step: none, y-tick-step: none, axis-style: "left", plot-style: plot.palette.rainbow, { plot.add( domain: (0, 5), x => calc.pow(calc.e, -x)) } ) })] === Trasformate razionali <poli_e_zeri> Di particolare importanza sono le _trasformate razionali_, cioè quelle in cui $ F(s) = frac(N(s),D(s)) $<trasformate_razionali> con $N(s)$ e $D(s)$ polinomi primi tra loro. Le radici di $N(s)=0$ si dicono *zeri* e quelle di $D(s)=0$ si dicono *poli*: nell'insieme, poli e zeri si dicono _singolarità_. Se $f$ è reale allora i coefficienti dei polinomi $N(s)$ e $D(s)$ sono reali. === Esempio $ F(s) = frac(s^2+2s, (s+1)(s+3)) = frac(s(s+2), (s+1)(s+3)) $ allora - zeri di $F(s)$: $0$ e $-2$ - poli di $F(s)$: $-1$ e $-3$ == Formula di antitrasformazione La funzione trasformanda può essere ricavata dalla sua trasformata mediante la _formula di antitrasformazione_ $ f(t) = frac(1, 2 pi j) integral _( sigma-j infinity)^( sigma+j infinity) F(s) e^(s t) thin d s $ *Notazione:* indichiamo l'antitrasformata di Laplace con $ cal(L)^(-1)$ tale che #tageq($F(s) xarrow(width: #3em, #text(size: 10pt)[$cal(L)^(-1)$] ) f(t)$, $sigma > overline( sigma)$) indichiamo la formula di antitrasformazione con $f(t) = cal(L)^(-1)[F(s)]$. La $f(t)$ è fornita per $t >= 0$, perché solo nei punti di continuità in cui la $f$ è maggiore di zero essa contribuisce a determinare $F$. L'antitrasformata fornisce $f(t)=0$ per $t<0$, per questo la corrispondenza tra $f(t)$ e $F(s)$ è *biunivoca*. === Perché si utilizza la trasformata di Laplace #cfigure("Images/Motivo_Laplace.png", 70%) Se, provando a risolvere il problema oggetto, risulta difficile arrivare alla soluzione oggetto (magari perché i calcoli sono molto complessi o risulta poco conveniente in termini di risorse), allora si trasforma il problema oggetto in problema immagine con la trasformata di Laplace se risulta poi conveniente (o semplice) arrivare alla soluzione immagine, per poi antitrasformarla per ottenere la soluzione oggetto che si stava cercando. == Proprietà della trasformata di Laplace === Linearità Dati $f(t)$ e $g(t)$ tali per cui esistono le trasformate $F(s)$ e $G(s)$, allora $ forall alpha in CC, forall beta in CC$ risulta $ cal(L)[ alpha f(t) + beta g(t)] = alpha cal(L)[f(t)] + beta cal(L)[g(t)] = alpha F(s) + beta G(s) $<linearità_Laplace> #heading(numbering: none, level: 3)[Dimostrazione] $ cal(L)[alpha f(t) + beta g(t)] &= integral_(0^(-))^(+ infinity) ( alpha f(t) + beta g(t) ) e^(-s t) d t\ &= alpha underbrace( integral_(0^(-))^(+ infinity) f(t)e^(-s t) d t,F(s)) + beta underbrace( integral_(0^(-))^(+ infinity) g(t)e^(-s t) d t,G(s))\ &= alpha F(s) + beta G(s) $ === Traslazione temporale $ cal(L)[f(t- tau)] = e^(- tau s)F(s) space forall tau >0 $<traslazione_temporale_Laplace> $ tau$ deve essere maggiore di 0, altrimenti la $f(t)$ sarebbe diversa da 0 per un tempo negativo. #heading(numbering: none, level: 3)[Dimostrazione] $ cal(L)[f(t- tau)] &= integral_(0^-)^(+ infinity) f(t - tau)e^(-s t) thin d t\ & =_(rho = t- tau) integral_(- tau^-)^(+ infinity) f( rho)e^(-s( rho+tau)) thin d rho $ siccome la $f(t)$ è nulla per $t<0$ posso riscrivere gli estremi di integrazione $ integral_(0^-)^(+ infinity) f( rho)e^(-s( rho+tau)) d rho &= underbrace( integral_(0^-)^(+ infinity) f( rho)e^( rho) d rho,F(s)) dot e^(-s tau)\ &= F(s) e^(-s tau) $ come volevasi dimostrare $ cal(L)[f(t- tau)] = e^(- tau s)F(s) $ === Traslazione nel dominio della variabile complessa $ cal(L)[e^( alpha t )f(t)] = F(s - alpha) $<Traslazione_dominio_variabile__complessa_Laplace> === Dimostrazione $ cal(L)[e^( alpha t )f(t)] &= integral_(0^-)^(+ infinity) f(t)e^( alpha t) dot e^(-s t) thin d t \ &= integral_(0^-)^(+ infinity) f(t)e^(-(s- alpha)t) thin d t \ &= F(s- alpha) $ === Derivazione nel dominio del tempo $ cal(L) [ frac(d, d t)f(t) ] = s F(s) - f(0) $<Derivazione_nel_dominio_del_tempo> Calcoliamo la trasformata della derivata seconda $ cal(L) [ frac(d^2,d t^2)f(t) ] &= cal(L) [ frac(d, d t) underbrace( [ frac(d, d t)f(t) ],g(t)) ]\ &=s G(s) - g(0)\ &=s G(s) - f'(0)\ &=s(s F(s)-f(0)) - f'(0)\ &= s^2 F(s) - s f(0) - f'(0) $ Quindi possiamo definire la _derivata n-sima nel tempo_ $ cal(L) [ frac(d^n, d t^n)f(t) ] = s^n F(s) - sum_(i=1)^n s^(n-i) lr(frac(d^(i-1), d t^(i-1))f(t)|)_(t=0) $<derivata_n-sima_Laplace> La proprietà ci dice che, se la funzione e le sue derivate si annullano in $t=0$, derivare nel dominio del tempo equivale a moltiplicare per $s$ nel dominio della variabile complessa; infatti $s$ viene chiamato _operatore di derivazione_. === Derivazione nel dominio della variabile complessa Supponiamo $F(s)$ derivabile per tutti gli $s$; allora risulta $ cal(L)[t f(t)] = -frac(d F(s), d s) $<derivazione_dominio_variabile_complessa> la quale è estendibile al caso della trasformata $t^n dot f(t)$. #heading(numbering: none, level: 3)[Dimostrazione] Considerando che $t e^(-s t) = - dfrac(d, d s)e^(-s t)$ $ cal(L)[t f(t)] &= integral_(0^+)^(+ infinity) t f(t)e^(-s t) thin d t\ &= integral_(0^+)^(+ infinity) f(t) underbrace(t e^(-s t),- frac(d, d s)e^(-s t)) thin d t\ &= integral_(0^+)^(+ infinity) f(t) (- frac(d,d s)e^(-s t) ) thin d t\ &=- frac(d,d s) underbrace( integral_(0^+)^(+ infinity) f(t) e^(-s t) thin d t,F(s))\ &= - frac(d F(s), d s) $ === Integrazione nel tempo Supponiamo che la funzione $f(t)$ sia integrabile tra 0 e $+ infinity$. Allora $ cal(L) [ integral_0^t f( tau) d tau ] = frac(1, s) F(s) $ #par(leading: 1.2em)[La proprietà ci dice che integrare nel dominio del tempo equivale a dividere per $s$ nel dominio della variabile complessa; infatti $dfrac(1, s)$ viene chiamato _operatore di integrazione_.] === Convoluzione nel tempo Date due funzioni $f_1$ e $f_2$, il loro _prodotto di convoluzione_ è $ f_1(t) ast f_2(t) = integral_(- infinity)^(+ infinity) f_1(t - tau)f_2(t) d tau = integral_(- infinity)^(+ infinity) f_1( eta)f_2( eta) d eta = f_2(t- eta) ast f_1(t) $<prodotto_convoluzione> e si trova $ cal(L)[f_1(t) ast f_2(t)] = F_1(s) dot F_2(s) $<convoluzione_tempo_Laplace> === Teorema del valore iniziale Se una funzione reale $f(t)$ ha trasformata razionale $F(s)$ con grado del denominatore maggiore del grado del numeratore, allora $ f(0) = lim_(s arrow infinity) s F(s) $<valore_valore_iniziale> Se $f$ è una funzione discontinua di prima specie in $t=0$, $f(0)$ si interpreta come $f(0^+)$. L'equazione vale se $f(0)$ o $f(0^+)$ esistono. === Teorema del valore finale<teorema_valore_finale> Se una funzione reale $f(t)$ ha trasformata razionale $F(s)$ con grado del denominatore maggiore del grado del numeratore e poli nulli o con parte reale negativa, allora $ lim_(t arrow + infinity) f(t) = lim_(s arrow 0) s F(s) $<teorema_valore_finale_eq> L'equazione vale se $ display(lim_(t arrow + infinity)f(t))$ esiste. == Trasformata di segnali elementari Definiamo il _delta di Dirac_ $ delta(t)$ tale che $ integral_(0^-)^(0^+) delta(t) thin d t = 1 $<delta_Dirac> #align(center)[ #table( columns: (auto, auto), align: horizon, stroke: none, $cal(L)[ delta(t)]=1$, image("Images/Delta.png", width: 60%), $ cal(L)[1(t)]= dfrac(1, s)$, image("Images/Scalino.png", width: 60%), $ cal(L)[t dot 1(t)]= dfrac(1, s^2)$, image("Images/Scalino_2.png", width: 60%), $ cal(L)[e^( alpha t) dot 1(t)]= dfrac(1,s- alpha)$, image("Images/Scalino_3.png", width: 60%), ) ] === Trasformata della delta $ cal(L)[ delta(t)] &= integral_(0^-)^(+ infinity) delta(t) e^(-s t) thin d t \ &= integral_(0^-)^0 delta(t) underbrace(e^(-s dot 0),1) d t + underbrace( integral_(0^+)^(+ infinity) underbrace( delta(t),0) e^(-s t) thin d t,0) $ === Trasformata del segnale gradino unitario Il segnale gradino unitario $1(t)$ è definito $ 1(t) = cases( 0 &wide t<0\ 1 &wide t >= 0 ) $ $ integral_(0^-)^(+ infinity) 1(t)e^(-s t)thin d t &= integral_(0)^(+ infinity) underbrace(1(t),1)e^(-s t)thin d t\ &= integral_(0)^(+ infinity)e^(-s t) thin d t\ &= lr(frac(e^(-s t), -s) |)_(t arrow+ infinity) - lr(frac(e^(-0), -s) |)_(t=0) $ $ lim_(t arrow+ infinity)e^(-s t)=0$, $e^0=1$ $ underbrace(lr(size: #60%,frac(overbrace(e^(-s t), 0), -s) |)_(t arrow+ infinity), 0) -lr(size: #60%, frac(overbrace(e^(-0), 1),-s) |)_(t=0) = frac(1, s) $ === Trasformata del segnale rampa Il segnale _rampa_ $r(t)$ è definito come $ r(t) = cases( 0 &wide t<0\ t &wide t >= 0 ) space #image("Images/Segnale_rampa.png",width: 35%) $ Per calcolare la trasformata del segnale rampa utilizziamo la proprietà di @eqt:derivazione_dominio_variabile_complessa[derivazione nel dominio della variabile complessa] $ cal(L)[t dot 1(t)] &= - frac(d ( dfrac(1, s) ), d s) \ &= frac(1, s^2) $ Mentre per calcolare la trasformata del gradino moltiplicato un esponenziale utilizziamo la proprietà di @eqt:Traslazione_dominio_variabile__complessa_Laplace[di traslazione nel dominio della variabile complessa]. $ cal(L) lr(size: #30%, [e^( alpha t) underbrace(1(t),f(t))]) &= underbrace(F(s- alpha),F(s)= frac(1, s)) \ &= frac(1,s- alpha) $ == Tabella delle trasformate <Tabella_trasformate> #align(center)[ #table( columns: (auto, auto), align: horizon, stroke: none, row-gutter: 10pt, $ cal(L)[ delta(t)]=1$, image("Images/Delta.png", width: 65%), $ cal(L)[1(t)]= dfrac(1,s)$, image("Images/Scalino.png", width: 65%), $ cal(L)[t dot 1(t)]= dfrac(1,s^2)$, image("Images/Scalino_2.png", width: 65%), $ cal(L)[e^( alpha t) dot 1(t)]= dfrac(1,s- alpha)$, image("Images/Scalino_3.png", width: 65%), $ cal(L)[ sin( omega t)1(t)]= dfrac(omega, s^2+ omega^2)$, image("Images/Trasformata_seno.png", width: 65%), $ cal(L)[ cos( omega t)1(t)]= dfrac(omega, s^2+ omega^2)$, image("Images/Trasformata_coseno.png", width: 65%), $ cal(L)[ sin( omega t + phi)1(t)]= dfrac( omega cos phi plus.minus s sin phi, s^2+ omega^2)$, [], $ cal(L)[ cos( omega t + phi)1(t)]= dfrac(s cos phi minus.plus omega sin phi, s^2+ omega^2)$ ) ] = Funzione di trasferimento == Introduzione Consideriamo il sistema LTI con $x in RR^n, u in RR^m,y in RR^p$ $ dot(x)(t) &= A x(t) + B u(t)\ y(t) &= C x(t) + D u(t) $ con $x(0) = x_0$. Siano $X(s):= cal(L)[x(t)], U(s):= cal(L)[u(t)]$ e $Y(s):= cal(L)[y(t)]$. Applichiamo la trasformazione di Laplace ad ambo i membri delle equazioni precedenti, ricordando che $ cal(L) [ dfrac(d, d t)x(t) ]=s X(s)-x(0)$ $ s X(s) - x(0) &= A X(s) + B U(s)\ Y(s) &= C X(s) + D U(s) $ se raccolgo $X(s)$ nella prima equazione $ (s I-A)X(s) =& x_0+ B U(s) \ Y(s) =& C X(s) + D U(s) $ $ X(s) &= overbrace((s I-A)^(-1)x_0, X_ ell (s)) + overbrace((s I-A)^(-1) B U(s),X_f (s)) \ Y(s) &= C X(s) + D U(s) $ Sottolineiamo che se avessimo un sistema generico non si potrebbe riscrivere come abbiamo fatto perché #underline[le matrici devono essere costanti]. Inoltre per poter scrivere un sistema LTI come sopra la matrice $(s I-A)$ deve essere invertibile; una matrice è invertibile se il suo determinante è non nullo, quindi, se $s$ è autovalore della matrice della dinamica e $p(s)$ è il polinomio caratteristico associato: $ p(s) = det (s I-A) $ Quindi le trasformate dello stato e dell'uscita del sistema in funzione di $x_0$ e $U(s)$ sono $ X(s) &= overbrace((s I-A)^(-1)x_0, "evoluzione libera") + overbrace((s I-A)^(-1) B U(s), "evoluzione forzata")\ Y(s) &= underbrace(C(s I-A)^(-1)x_0, "evoluzione libera") + underbrace((C(s I-A)^(-1)B+D)U(s), "evoluzione forzata") $ $ X_ ell (s) &= (s I-A)^(-1)x_0 &space X_f(s) &= (s I-A)^(-1) B U(s) \ Y_ ell (s) &= C(s I-A)^(-1)x_0 & Y_f(s) &= (C(s I-A)^(-1)B+D )U(s) $ Consideriamo ora la trasformata dell'evoluzione forzata dell'uscita $ Y_f (s) = (C(s I-A)^(-1)B+D ) U(s) $ la matrice $ G(s) = C(s I-A)^(-1)B+D $ è detta _funzione di trasferimento_; se il sistema è SISO (Single Input Single Output) è una funzione scalare. Abbiamo così ottenuto una *rappresentazione ingresso-uscita* $ Y_f (s) = G(s)U(s) $<rappresentazione_ingresso_uscita> se assumiamo che $x(0)=0$ otteniamo esattamente la trasformata di Laplace dell'uscita $y$ $ Y(s) = G(s)U(s) $<funzione_di_trasferimento> Due osservazioni: #list( marker: [#text(8pt)[$triangle.filled$]], [se si conosce la funzione di trasferimento $G(s)$ di un sistema e la trasformata di Laplace $U(s)$ dell'ingresso, è possibile calcolare, mediante antitrasformazione dell'equazione precedente @eqt:funzione_di_trasferimento[], il movimento forzato $y_f$ dell'uscita (che ovviamente coincide con il movimento $y$ se lo stato iniziale è nullo);], [la funzione di trasferimento è data dal rapporto tra la trasformata dell'uscita e dell'ingresso nel caso di $x(0)=0$ $ G(s) = frac(Y(s),U(s)) $] ) == Richiami di calcolo matriciale === Matrice diagonale Una _matrice diagonale_ è una matrice quadrata tale che per $i != j$ si ha sempre $a_(i j)=0$ (ogni matrice diagonale è simmetrica). $ mat(gap: #0.8em, 1,0,0,0; 0,7,0,0; 0,0,9,0; 0,0,0,-3 ), mat(gap: #0.9em, 0,0,0,0; 0,2,0,0; 0,0,3,0; 0,0,0,1 ) $ === Matrice triangolare alta Una _matrice triangolare alta_ è una matrice quadrata tale che per $i>j a_(i j)=0$ $ mat(gap: #0.8em, a_(11),a_(12),a_(13),a_(14); a_(21),a_(22),a_(23),a_(24); a_(31),a_(32),a_(33),a_(34); a_(41),a_(42),a_(43),a_(44) ) arrow mat(gap: #0.8em, 1,4,-3,7; 0,6,-8,9; 0,0,3,-5; 0,0,0,1 ) $ === Matrice triangolare bassa Una _matrice triangolare alta_ è una matrice quadrata tale che per $i<j a_(i j)=0$ $ mat(gap: #0.8em, a_(11),a_(12),a_(13),a_(14); a_(21),a_(22),a_(23),a_(24); a_(31),a_(32),a_(33),a_(34); a_(41),a_(42),a_(43),a_(44); ) arrow mat(gap: #0.8em, 1,0,0,0; 6,7,0,0; 3,-2,-9,0; 5,4,-8,3; ) $ Nota: una matrice diagonale è triangolare alta e triangolare bassa. === Matrice identità $ I_n = mat(gap: #0.8em, 1 , 0 , dots , 0 ; 0 , dots.down , dots , dots; dots.v , dots.v , dots.down , dots.v; 0 , dots , dots , 1 ) space I_2 = mat(gap: #0.8em, 1 , 0; 0 , 1; ) $ === Trasposta di una matrice $ mat(gap: #0.8em, 2 , 1 , 7; 4 , 0 , 2 )^T = mat(gap: #0.8em, 2 , 4; 1 , 0; 7 , 2 ) $ $A = (a_(i j))$ significa che l'elemento di posto $(i,j)$ in $A$ è $a_(i,j)$. $A^T := B = (b_(i j))$ con $b_(i j) = a_(j i)$ per ogni coppia di indici $(i,j)$. === Complemento algebrico Definiamo $ hat(A)_(i j)$ complemento algebrico dell'elemento $a_(i j)$ il determinante della matrice ottenuta eliminando da $A$ la riga $i$ e la colonna $j$ (che chiamiamo $M$) e moltiplicando per $(-1)^(i+j)$ $ hat(A)_(i j) = (-1)^(i+j) det(M) $ === Determinante di una matrice Il determinante di una matrice generica si calcola $ det(A) = sum_(i=1)^n a_(i j) hat(A)_(i j) = sum_(j=1)^n a_(i j) hat(A)_(i j) $ == Funzione di trasferimento nel dettaglio La funzione di trasferimento è definita $ G(s) = C(s I-A)^(-1)B + D $ con $C$ matrice $1 times n$ e $B$ matrice $m times 1$. Definiamo ora la *matrice aggiunta* $ "adj"(A)$ come matrice dei complementi algebrici di $A$ $ "adj"(A) = mat(delim: "[", hat(A)_(11) , hat(A)_(12) , dots , hat(A)_(n 1); hat(A)_(12) , hat(A)_(22) , dots , hat(A)_(n 2); dots.v , dots.v , dots.down , dots.v; hat(A)_(n 1) , hat(A)_(n 2) , dots , hat(A)_(n n) ) $ La matrice inversa può essere definita con la matrice aggiunta: $ A^(-1) = frac( "adj"(A), det(A)) $ Quindi, se consideriamo la nostra matrice $(s I-A)$ $ (s I-A)^(-1) = frac( "adj"(s I-A), underbrace( det(s I-A), "polinomio" \ "caratteristico di " A)) $ quindi scriviamo la matrice aggiunta di $(s I-A)$ $ "adj"(s I-A) = mat(delim: "[", hat((s I-A))_11 , hat((s I-A))_12 , dots , hat((s I-A))_(n 1); hat((s I-A))_12 , hat((s I-A))_22 , dots , hat((s I-A))_(n 2); dots.v , dots.v , dots.down , dots.v; hat((s I-A))_(n 1) , hat((s I-A))_(n 2) , dots , hat((s I-A))_(n n) ) $ matrice di polinomi in $s$ al più di grado $n-1$; il determinante di $s I-A$ è un polinomio in $s$ di grado $n$. Per cui $ (s I-A)^(-1) = underbrace(frac(1, det(s I-A)), "scalare") dot "adj"(s I-A) $ Allora possiamo scrivere la funzione di trasferimento come $ G(s) = frac(overbrace(N_(s p)(s), "polinomio di" \ "grado al più" n-1), underbrace(D_(s p)(s), "polinomio " \ "di grado" n)) + underbrace(D, "polinomio non " \ "strettamente" \ "proprio") $ in forma estesa: $ G(s) = frac(N(s),D(s)) = frac(beta_( nu)s^( nu) + beta_( nu-1)s^( nu-1) + dots + beta_1s + beta_0,s^(nu #footnote[trasformata della delta di Dirac] ) + alpha_( nu-1)s^( nu-1) + dots + alpha_1s + alpha_0) $ Le radici di $N(s)$ si dicono *zeri*, le radici di $D(s)$ si dicono *poli*; i poli sono radici di $ det(s I-A)$ quindi sono autovalori di $A$. Poli e zeri sono reali o complessi coniugati, poiché radici di polinomi a coefficienti reali. === Esempio 1 #par(leading: 1.2em)[Se prendiamo $y(t) = dfrac(d,d t) u(t)$, allora la sua trasformata sarà $Y(s)=s U(s)$, quindi la funzione di trasferimento del sistema è $G(s)=s$; il sistema non è causale, perché il grado del numeratore ha grado maggiore di quello del denominatore.] Questa considerazione diventa evidente se si utilizza la definizione di derivata: $ y(t) = frac(d, d t)(u(t)) = lim_(h arrow 0) frac(u(t+h)-u(t),h) $ infatti per conoscere la derivata in $t$ devo conoscere il valore del segnale in $t+h$. === Esempio 2 $ y(t) &= integral_(0)^t u(tau) d t &space space Y(s) &= frac(1,s)U(s) $ in questo caso $G(s) = dfrac(1,s)$, quindi il grado del denominatore è maggiore di quello del numeratore, per questo il sistema è causale. == Schema dell'utilizzo della trasformata di Laplace #cfigure("Images/Schema_trasformata.png", 70%) == Rappresentazioni e parametri della funzione di trasferimento Può essere conveniente, in alcune situazioni, rappresentare la funzione di trasferimento in una delle seguenti forme fattorizzate $ G(s) = frac(rho product_i (s + z_i) product_i (s^2+2 zeta_i alpha_(n i)s + alpha^2_(n i)), s^g product_i (s + p_i) product_i (s^2+2 xi_i omega_(n i)s + omega^2_(n i))) $<parametrizzazione_1> $ G(s) = frac(mu product_i (1 + tau_i s) product_i (1 + frac(2 zeta_i, alpha_(n i)) + frac(s^2, alpha^2_(n i))), s^g product_i (1 + T_i s) product_i (1 + frac(2 xi_i, omega_(n i)) + frac(s^2, omega^2_(n i)))) $<Forma_di_Bode> *N.B.* il pedice $n$ sta per "naturale". Con - lo scalare $ rho$ è detto costante di trasferimento, $ mu$ il _guadagno_; - l'intero $g$ è detto _tipo_; - gli scalari $-z_i$ e $-p_i$ sono gli zeri e i poli reali non nulli; - gli scalari $ alpha_(n i) > 0$ e $ omega_(n i) > 0$ sono le _pulsazioni naturali_ delle coppie di zeri e poli complessi coniugati; - gli scalari $ zeta_i$ e $ xi_i$, in modulo minori di 1, sono gli _smorzamenti_ degli zeri e dei poli complessi coniugati; - gli scalari $ tau_i != 0$ e $T_i != 0$ sono le costanti di tempo La seconda equazione @eqt:Forma_di_Bode[] è detta _forma di Bode_. === Esempio $ G(s) = 10 dot frac(overbrace(s+10, product_i (s+z_i)),s^2(s+1)(s+100)) $ $ z_1 &= 10 \ p_1 &= 1 &space p_2 &= 100\ rho &= 10 & g &= 2 $ C'è un solo zero, che è $-10$, mentre i poli sono $0,-1,-100$. Scriviamo la funzione di trasferimento nella seconda forma (di Bode): $ G(s) = frac(cancel(10),s^2) dot frac(cancel(10) dot (1 + dfrac(s,10) ), cancel(100)(1+s) (1 + dfrac(s,100) )) = 1 dot frac((1 + 0.1 s), s^2(1+s)(1+10^(-2)s)) $ $ mu &= 1 &space space tau_1 &= 0.1\ T_1 &= 1 & T_2 &= 10^(-2) $ Prendiamo un polinomio di II grado del denominatore $ s^2 + 2 xi_i omega_(n i)s + omega^2_(n i) $ le radici del polinomio sono: $ s_(1 slash 2) &= - xi_i omega_(n i) plus.minus sqrt( xi_i^2 omega_(n i)^2 - omega_(n i)^2)\ &=- xi_i omega_(n i) plus.minus omega_(n i) sqrt( xi_i^2 - 1) $ Se $|xi_i|<1$ abbiamo dei _poli complessi coniugati_ $ s_(1 slash 2) = - xi_i omega_(n i) + j omega_(n i) sqrt(1 - xi_i^2) $ \ $ |s_1| = |s_2| &= sqrt( xi_i^2 omega_(n i)^2 + omega_(n i)^2 (1 - xi_i^2))\ &= sqrt( xi_i^2 omega_(n i)^2 + omega_(n i)^2 - omega_(n i)^2 xi_i^2) &= omega_(n i) $ Rappresentiamo i poli nel piano complesso: #cfigure("Images/Poli_piano.png", 50%) $ omega_(n i)$ quindi è il modulo delle radici, $ xi_i$ ci da invece informazioni sull'angolo delle radici nel piano complesso: se $ xi_i>0$ si hanno dei poli a parte reale negativa, se $ xi_i<0$ si hanno dei poli a parte reale positiva. Se $ xi_i=0$ gli autovalori sono immaginari puri, quindi i modi del sistema sono sinusoidi non smorzate, dato che lo smorzamento è nullo. Nella rappresentazione classica si una una _x_ per i poli e un $circle$ per gli zeri #cfigure("Images/Poli_rapp_classica.png", 70%) == Cancellazioni === Esempio 1 $ dot(x)_1 &= -x_1 + x_2\ dot(x)_2 &= -2x_2 + u\ y &= x_2 $ $ G(s) &= C(s I-A)^(-1) B\ &= mat(delim: "[", 0 , 1 ) mat(delim: "[", s+1 , -1; 0 , s+2 )^(-1) mat(delim: "[", 0 , 1 )\ &= mat(delim: "[", 0 , 1 ) mat(delim: "[", frac(s+2,(s+1)(s+2)) , frac(1,(s+1)(s+2)); 0 , frac(s+2,(s+1)(s+2)) )^(-1) mat(delim: "[", 0 , 1 )\ &= frac(cancel(s+1), cancel((s+1))(s+2))\ &= frac(1,s+2) $ Guardando questo esempio ci verrebbe da pensare che le cancellazioni sono innocue, questo perché stiamo cancellando il polinomio associato a un autovalore reale negativo, che quindi fa convergere il mio sistema. Cosa diversa è se cancelliamo un polinomio associato a un autovalore reale positivo. === Esempio 2 Infatti se prendiamo un sistema di questo tipo $ dot(x)_1 &= x_1 + x_2\ dot(x)_2 &= x_2 + u\ y &= x_2 $ la funzione di trasferimento di questo sistema è $ G(s) = frac(cancel((s-1)), cancel((s-1))(s+2)) = frac(1,s+2) $ In questo caso stiamo cancellando un polinomio associato a un autovalore reale positivo, che quindi fa #underline[divergere] il sistema, perciò bisogna stare attenti quando si eseguono cancellazioni. Non basta guardare la funzione di trasferimento per conoscere l'andamento del sistema. == Antitrasformazione di Laplace Ricordiamo che la trasformata della risposta di un sistema Lineare Tempo Invariante (LTI) singolo ingresso singola uscita (SISO) è data da $ Y(s) = C(s I-A)^(-1) x(0) + G(s)U(s) $ con $C(s I-A)^(-1) in RR^(1 times n)$. Si può far vedere che gli elementi di $C(s I-A)^(-1)$ sono rapporti di polinomi. Nel corso della trattazione considereremo ingressi tali che $U (s)$ sia un rapporto di polinomi. Quindi possiamo scrivere $ Y(s) = frac(N(s),D(s)) $ con $N (s)$ e $D(s)$ opportuni polinomi. Ricordiamo che per $x(0)=0$ (risposta forzata) $ Y(s)=G(s)U(s) $ Quindi, applicando in ingresso una delta di Dirac $u(t)= delta(t)$, che ha trasformata $U(s)=1$, si ha $ Y(s) = G(s) $ per questo per la risposta all'impulso le radici di $D(s)$ sono i poli di $G(s)$. = Sviluppo di Heaviside o in fratti semplici (poli distinti) == Caso 1: poli reali o complessi coniugati distinti con molteplicità 1 Possiamo scrivere $Y(s)$ come $ Y(s) = frac(N(s),D(s)) = frac(N(s), product_(i=1)^n (s + p_i)) = sum_(i=1)^n frac(k_i,s+p_i) $ con $k_i$ detti residui. Consideriamo $ (s+p_i) lr(frac(N(s),D(s)) |)_(s = -p_i) = sum_( j=1 \ j != i)^n lr(frac(k_j (s+p_i),s+p_j) |)_(s=-p_i) + k_i $ quindi ciascun residuo $k_i$ può essere calcolato come $ k_i = (s+p_i) lr(frac(N(s),D(s)) |)_(s=-p_i) $ *N.B.* $k_i$ reali se associati a poli reali, complessi coniugati se associati a una coppia di poli complessi coniugati. Quindi, antitrasformando $Y(s)$ sviluppata in fratti semplici $ y(t) = cal(L)^(-1) [Y(s) ] = sum_(i=1)^n k_i cal(L) [ frac(1,s+p_i) ] = sum_(i=1)^n k_i e^(-p_i t) 1(t) $ === Esempio Vogliamo scrivere la $Y(s)$ in questo modo: $ Y(s) = frac(s^2+s+1,(s+2)(s+10)(s+1)) = frac(k_1,s+2) + frac(k_2,s+10) + frac(k_3,s+1) $ allora $ lr((s+2)Y(s) |)_(s=-2) &= [frac( cancel((s+2))k_1, cancel(s+2)) + frac(overbrace((s+2),0)k_2,s+10) + frac(overbrace((s+2),0)k_3,s+1) ]_(s=-2)\ &= k_1 $ lo riscrivo con $Y(s)$ nella forma "originale" $ lr((s+2)Y(s) |)_(s=-2) &= lr(frac(cancel((s+2))(s^2+s+1), cancel((s+2))(s+10)(s+1)) |)_(s=-2)\ &= frac((-2)^2 + (-2)+1,(-2+10)(-2+1)) &= - frac(3,8) $ ergo $ k_1 = - frac(3,8) $ Calcoliamo anche le altre costanti $ lr((s+10)Y(s) |)_(s=-10) &= lr(frac(cancel((s+10))(s^2+s+1),(s+2) cancel((s+10))(s+1)) |)_(s=-10) \ &= frac((-10)^2 + (-10)+1,(-10+2)(-10+1))\ &= frac(91,72) = k_2 $ $ lr((s+1)Y(s) |)_(s=-1) &= lr(frac(cancel((s+1))(s^2+s+1),(s+2)(s+10) cancel((s+1))) |)_(s=-1) \ &= frac((-1)^2 + (-1)+1,(-1+2)(-1+10)) \ &= frac(1,9) = k_3 $ Quindi possiamo scrivere la $Y(s)$ come $ Y(s) = -frac(3,8) underbrace(frac(1,s+2), #h(2em) arrow.b cal(L)^(-1) \ e^(-2t) 1(t)) + frac(91,72) underbrace(frac(1,s+10), #h(2em) arrow.b cal(L)^(-1) \ e^(-10t) 1(t)) + frac(1,9) underbrace(frac(1,s+1), #h(2em) arrow.b cal(L)^(-1) \ e^(-t) 1(t)) $ calcoliamo l'uscita del sistema con la formula di antitrasformazione $ y(t) &= cal(L)^(-1) [Y(s)]\ &= - frac(3,8) cal(L)^(-1) [ frac(1,s+2) ] + frac(91,71) cal(L)^(-1) [ frac(1,s+10) ] + frac(1,9) cal(L)^(-1) [ frac(1,s+1) ] \ &=- frac(3,8) e^(-2t)1(t) + frac(91,71) e^(-10t)1(t) + frac(1,9) e^(-t)1(t) $ #align(center)[ #cetz.canvas({ import cetz.draw: * content((3.1, 5.8), [$e^(-2t)$], name: "text") content((5.1,4.1), [$e^(-2t)1(t)$]) plot.plot( size: (8,6), x-tick-step: none, y-tick-step: none, y-min: -2, y-max: 2, x-min: -3, x-max: 3, axis-style: "school-book", { plot.add( domain: (0, 3), x => calc.pow(calc.e, -2*x), style: (stroke: black) ) plot.add( domain: (-0.5, 0), x => calc.pow(calc.e, -2*x), style: (stroke: (dash: "dashed")) ) } ) }) ] *N.B.* $1(t)$ definisce la funzione solo per $t >= 0$. === Forma reale per poli complessi coniugati Consideriamo la coppia di poli complessi coniugati $ p_(i,1) &= sigma + j omega &space space p_(i,2) &= sigma - j omega $ con residui associati (complessi coniugati) $ k_(i,1) &= M e^(-j phi) &space space k_(i,2) &= M e^(j phi) $ L'antitrasformata dei due termini associati è data da (ricordando la @Tabella_trasformate[]) $ cal(L)^(-1) [frac(k_(i,1), s+p_(i,1)) + frac(k_(i,2),s+p_(i,2)) ] &= M e^(-j phi) e^(-p_(i,1)t)1(t) + M e^(j phi) e^(-p_(i,2)t)1(t)\ &= M e^(-j phi) e^(-( sigma + j omega)t)1(t) + M e^(j phi) e^(-( sigma - j omega)t)1(t)\ &= 2M e^(- sigma t) (e^(-j( omega t + phi)) + e^(j( omega t + phi)) )1(t)\ &= 2M e^(- sigma t) frac((e^(-j( omega t + phi)) + e^(j( omega t + phi)) ),2) 1(t)\ frac(e^(j alpha) + e^(-j alpha),2) = cos(alpha) ==> &= 2M e^(- sigma t) cos( omega t + phi) 1(t) $ //#pagebreak() === Modi naturali di poli reali distinti #cfigure("Images/Modi_naturali_poli_distinti_1.png", 70%) === Modi naturali di poli complessi coniugati distinti #cfigure("Images/Modi_naturali_poli_distinti_2.png", 70%) === Modi naturali di un sistema LTI: poli distinti #cfigure("Images/Modi_naturali_poli_distinti_3.png", 70%) == Caso 2: Poli reali o complessi coniugati multipli con molteplicità maggiore di 1 $ Y(s) = frac(N(s),D(s)) = frac(N(s), display(product_(i=1)^q) (s + p_i)^(n_i)) = sum_(i=1)^q sum_(h=1)^(n_i) frac(k_(i,h),(s+p_i)^h) $ con $k_(i,h), h=1, dots, n_i$ residui del poli $-p_i$. Consideriamo $ (s+p_i)^(n_i) frac(N(s),D(s)) &=(s+p_i)^(n_i) sum_(j=1 \ j!= i)^q sum_(h=1)^(n_j) frac(k_(j,h),(s+p_j)^h) + sum_(h=1)^(n_i) (s+p_i)^(n_i - h)k_(i,h)\ &=(s+p_i)^(n_i) sum_(j=1 \ j != i)^q sum_(h=1)^(n_j) frac(k_(j,h),(s+p_j)^h) + sum_(h=1)^(n_i-1) (s+p_i)^(n_i - h)k_(i,h) + k_(i,n_i) $ Quindi il residuo $k_(i,n_i)$ è dato da $ k_(i,n_i) = (s+p_i)^(n_i) lr(frac(N(s),D(s)) |)_(s=-p_i) $ Derivando $(s+p_i)^(n_i) dfrac(N(s),D(s))$ si calcolano gli altri residui come $ k_(i,h) = frac(1,(n_i-h)!) frac(d^(n_i-h),d s^(n_i-h)) lr([(s+p_i)^(n_i) frac(N(s),D(s)) ] |)_(s=-p_i) $ Antitrasformando $Y(s)$ sviluppata in fratti semplici, ricordando la @Tabella_trasformate[tabella delle trasformate] e la proprietà di @eqt:derivazione_dominio_variabile_complessa[derivazione nel dominio della variabile complessa] $ y(t) = cal(L)^(-1) [Y(s)] &= sum_(i=1)^q sum_(h=1)^(n_i) k_(i,h) cal(L)^(-1) [frac(1,(s+p_i)^h) ]\ &= sum_(i=1)^q sum_(h=1)^(n_i) k_(i,h) frac(t^(h-1),(h-1)!)e^(-p_i t)1(t) $ === Esempio Consideriamo la seguente trasformata di Laplace dell'uscita di un generico sistema $ Y(s) = frac(s+3,(s+1)^2(s+2)) = frac(k_(1,1),(s+1)) + frac(k_(1,2),(s+1)^2) + frac(k_(2),(s+2)) $ $ k_2 &= (s+2)Y(s) |_(s=-2) &space k_(1,2) = (s+1)^2 Y(s) |_(s=-1) $ $ k_2 &= cancel((s+2)) lr(frac((s+3),(s+1)^2 cancel((s+2))) |)_(s=-2) &space k_(1,2) &= cancel((s+1)^2) lr(frac((s+3), cancel((s+1)^2)(s+2)) |)_(s=-1)\ &= frac((-2+3),(-2+1)^2) & &= frac((-1+3),(-1+2))\ &=1 & &=2 $ $ lr(frac(d, d s) ((s+1)^2 Y(s) ) |)_(s=-1) &= frac(d, d s) [frac(k_(1,1)(s+1)^2,(s+1)) + frac(k_(1,2) cancel((s+1)^2), cancel((s+1)^2)) + frac(k_2(s+1)^2,s+2) ]_(s=-1)\ &= [k_(1,1) + 0 + k_2 frac(overbrace((s+1)^2,0)-2 overbrace((s+1),0)(s+2),(s+2)) ]_(s=-1)\ &= k_(1,1) $ $ k_(1,1) &= frac(d, d s) cancel((s+1)^2) lr(frac(s+3, cancel((s+1)^2)(s+2)) |)_(s=-1)\ &= frac(d,d s) lr(frac(s+3,s+2) |)_(s=-1)\ &= lr(frac((s+2)-(s+3`),(s+2)^2) |)_(s=-1)\ &= 1 $ quindi possiamo scrivere la $Y(s)$ come $ Y(s) = frac(k_(1,1),(s+1)) + frac(k_(1,2),(s+1)^2) + frac(k_(2),(s+2)) = frac(1,s+1) + frac(2,(s+1)^2) + frac(1,(s+2)) $ ricordando che $cal(L)^(-1) [dfrac(1,s^2)] = t 1(t)$ dalla @Tabella_trasformate[tabella delle trasformate] e che $cal(L)[e^(alpha t)f(t)] = F(s- alpha)$ dalla proprietà di @eqt:Traslazione_dominio_variabile__complessa_Laplace[traslazione nel dominio della variabile complessa], antitrasformiamo tutte le componenti della funzione di trasferimento $ cal(L)^(-1) [ frac(1,(s+1)) ] &= e^(-t) 1(t) &space cal(L)^(-1) [ frac(1,(s+2)) ] &= e^(-2t) 1(t) &space cal(L)^(-1) [ frac(1,(s+1)^2) ] &= e^(-t) t 1(t) $ $ y(t) &= k_(1,1)e^(-t)1(t) + k_(1,2) t e^(-t)1(t) + k_(2)e^(-2t)1(t)\ &= e^(-t)1(t) + 2 t e^(-t)1(t) +e^(-2t)1(t) $ === Forma reale per poli complessi coniugati con molteplicità maggiore di 1 Si può dimostrare che per una coppia di poli complessi coniugati $ sigma_i &+ j omega_i &space space sigma_i &- j omega_i $ con molteplicità $n_i$, il contributo elementare associato è dato da $ sum_(h=1)^(n_i) 2M_(i,h) frac(t^(h-1),(h-1)!) e^(- sigma_i t) cos( omega_i t + sigma_(i,h)) 1(t) $ Ad esempio, consideriamo la seguente funzione di trasferimento $ Y(s) = frac(N(s),(s^2+2 xi omega_n s + omega_n^2)) $ i poli della funzione sono $ & underbrace(- xi omega_n, sigma) + underbrace(j omega_n sqrt(1- xi^2), omega) &space space - xi omega_n - j omega_n sqrt(1- xi^2) $ quindi $ Y(s) = frac(N(s),(s + sigma + j omega) (s + sigma - j omega)) $ e il contributo elementare $ &2M_(1,1)e^(- sigma t) cos( omega t+ phi)1(t) + 2M_(1,2)t e^(- sigma t) cos( omega t + phi)1(t) \ =& 2M_(1,1)e^(- xi omega_n t) cos( omega_n sqrt(1 - xi^2)t+ phi)1(t) + 2M_(1,2)e^(- xi omega_n t) cos( omega_n sqrt(1 - xi^2)t+ phi)1(t) $ === Modi naturali di poli multipli Un modo naturale di un polo reale multiplo $-p_i$ è definito come $ frac(t^(h-1),(h-1)!) e^(-p_i t) 1(t) $ I modi naturali di una coppia di poli complessi coniugati multipli $-( sigma_i + j omega_i)$ e $-( sigma_i - j omega_i)$ sono definiti come $ frac(t^(h-1),(h-1)!) e^(- sigma_i t) cos( omega_i + phi_(i,h)) 1(t) $ #cfigure("Images/Modi_naturali_poli_multipli.png", 65%) === Modi naturali come risposta all'impulso Sappiamo che per $x(0)=0$ (risposta forzata) $ Y(s) = G(s) U(s) $ se applichiamo in ingresso una delta di Dirac $u(t)= delta(t)$ $ Y(s) = G(s) $ Quindi la risposta ad un impulso è una combinazione lineare dei modi naturali del sistema lineare tempo invariante (SISO) descritto da $G(s)$. == Risposta a un ingresso generico Ricordiamo che $ Y(s) = underbrace(C(s I-A)^(-1), #text(size: 6pt)[$dfrac(N_ ell (s),D(s))$] ) -x(0) + underbrace(G(s)U(s), #text(size: 6pt)[$dfrac(N_f (s),D_f (s)) dfrac(N_u (s),D_u (s))$]) $ in cui $C(s I-A)^(-1) x(0)$, $G(s)$ e $U(s)$ sono rapporti di polinomi. Quindi $ y(t) &= y_ ell(t) + y_f(t)\ &=y_ ell(t) + y_(f,G)(t) + y_(f,U)(t) $ in cui - $y_ ell (t)$ e $y_(f,G) (t)$ sono combinazioni lineari di modi naturali del sistema con matrici $A, B, C$ e $D$; - $y_(f,U) (t)$ è combinazione lineare di "modi" presenti nell'ingresso $u(t)$ (dovuti alle radici del denominatore di $U (s)$). == Risposta di sistemi elementari Ricordiamo la @eqt:parametrizzazione_1[formula di parametrizzazione] $ G(s) = frac(rho product_i (s + z_i) product_i (s^2+2 zeta_i alpha_(n i)s + alpha^2_(n i)), s^g product_i (s + p_i) product_i (s^2+2 xi_i omega_(n i)s + omega^2_(n i))) $ Consideriamo il caso di poli distinti. Da quanto visto fino ad ora risulta che per $x(0) = 0$ (risposta forzata) $ Y(s) = G(s)U(s) = sum_(i) frac(k_i,s+p_i) + sum_i frac(a_i s+b_i,s^2 + 2 xi_i omega_(n,i)s + omega^2_(n,i)) $ #cfigure("Images/Risposta_sistemi_elementari.png", 60%) == Stabilità esterna (BIBO) <BIBO> Un sistema si dice BIBO (Bounded-Input Bounded-Output) stabile se la sua uscita forzata è limitata per ogni ingresso limitato. Da quanto visto fino ad ora con lo sviluppo di Heaviside (fratti semplici) si può dedurre che un sistema con funzione di trasferimento $G(s)$ è BIBO stabile se e solo se tutti i poli di $G(s)$ sono a parte reale strettamente minore di zero. *N.B.* La BIBO stabilità è equivalente alla stabilità asintotica. = Analisi di sistemi attraverso funzione di trasferimento //in riferimento al pacchetto di slide "main_CAT_modulo2_part4" == Dalla Funzione di Trasferimento allo spazio degli stati Consideriamo la funzione di trasferimento $ G(s) = frac( mu,1+T s) $ Questo tipo di sistemi può essere rappresentato nello spazio degli stati (la rappresentazione non è unica) come $ dot(x) &= - frac(1,T) x + frac( mu,T) mu\ y &= x $ <sis_1_ordine> Infatti, la funzione di trasferimento associata alla @eqt:sis_1_ordine[] è $ G(s) = C(s I-A)^(-1) B = frac(mu,1+T s) $ dove - il parametro $T$ è la costante di tempo associata al polo; - il parametro $ mu$ è il _guadagno_ == Sistemi del primo ordine Definiamo un sistema nello spazio della funzione di trasferimento $ G(s) &= frac( mu,1+T s) &space U(s) = frac(k,s) $ $ Y(s) = G(s) U(s) = frac( mu k,s(1+T s)) $ con $ mu >0,k>0,T>0$; da notare che se $T<0$ il sistema è instabile perché si avrebbe un polo positivo. Allora mediante lo sviluppo di Heaviside e la formula di antitrasformazione troviamo che $ y(t) = mu k(1-e^(-t slash T))1(t) $ $y(0) = 0, thick dot(y)(0) = dfrac( mu k,T) , thick y_( infinity) = mu k$ #cfigure("Images/Sistemi_1_ordine_1.png", 50%) Definiamo il *tempo di assestamento $ T_(a, epsilon)$* come il tempo tale per cui #tageq($(1-0.01 epsilon)y_( infinity) <= y(t) <= (1+0.01 epsilon)y_( infinity) $, $ forall t >= T_(a, epsilon)$) === Esempio Consideriamo un sistema con $ G(s) = frac( mu,1+T s) = frac( mu,T) frac(1,s+ frac(1,T)) $ con ingresso $u(t)=k 1(t)$, quindi $U(s) = frac(k,s)$ $ Y(s) &= G(s) U(s)\ &= frac( mu,T) frac(1,s+ frac(1,T)) frac(k,s)\ &= frac(k_1,s+ frac(1,T)) + frac(k_2,s) $ $ y(t) &= cal(L)^(-1) underbrace( [ frac(k_1,s+ frac(1,T)) ],y_(G,t)) + cal(L)^(-1) underbrace( [ frac(k_2,s) ],y_(U,t))\ &= k_1 underbrace(e^(-t slash T) 1(t), "sistema") + k_2 underbrace(1(t), "ingresso") $ $ k_1 &= lr((s+ frac(1,T))Y(s) |)_(s=-1/T) &space k_2 &= s Y(s) |_(s=0)\ &= cancel( (s+ frac(1,T) )) frac( mu,T) lr(frac(k, ( cancel(s+ frac(1,T)) )s) |)_(s=-1/T) & &= frac( mu,T) lr(frac(k,s+ frac(1,T)) |)_(s=0)\ &= frac( mu,T) frac(k,- frac(1,T)) & &= mu k\ &= - mu k $ $ y(t) &= - mu k e^(-t/T)1(t) + mu k 1(t)\ &= mu k (1 - e^(-t/T)) 1(t) $ La risposta ottenuta ci dice che, dando in ingresso il gradino, il sistema ci metterà un po' per raggiungerlo, in base alla sua dinamica. Per quanto riguarda invece il tempo di assestamento, esso si calcola $ T_(a, epsilon) = T ln ( frac(1,0.01 epsilon) ) $ $ T_(a,5) & approx 3T &space space T_(a,1) & approx 4.6T $<tempo_assestamento> === Considerazioni - Per calcolare la risposta riscrivere $G(s) = dfrac( mu,T) dfrac(1,s+ frac(1,T))$ e sviluppare $Y (s) = G(s)U (s)$ in fratti semplici; - la risposta è monotona, i modi presenti sono $1(t)$ dell' ingresso e $e^(-t/T)$ del sistema; - il valore asintotico è $mu k$, quindi se l'ingresso fosse un riferimento $k$ da seguire, avremmo un errore a regime $e_( infinity) = |1- mu|k$. == Sistemi del secondo ordine La funzione di trasferimento di sistemi del secondo ordine è $ G(s) = mu frac( omega^2_n,s^2+2 xi omega_n + omega^2_n) $ Questo tipo di sistemi può essere rappresentato nello spazio degli stati come $ dot(x)_1 &= x_2\ dot(x)_2 &= - omega^2_n - 2 xi omega_n x_2 + mu omega^2_n u \ y &= x_1 $ dove - il parametro $ xi$ è il coefficiente di smorzamento; - il paramento $ omega_n$ è la pulsazione naturale; - il parametro $ mu$ è il guadagno. === Sistemi del secondo ordine con poli complessi coniugati $ G(s) &= mu frac( omega^2_n,s^2+2 xi omega_n + omega^2_n) & U(s) &= frac(k,s)\ Y(s) &= G(s)U(s) = mu k frac( omega^2_n,s(s^2+2 xi omega_n + omega^2_n)) $ con $|xi|<1$ e $ omega_n > 0$ $ y(t) = mu k(1 - A e^(- xi omega_n t) sin( omega t + phi))1(t) $ $ A &= frac(1, sqrt(1- xi^2)) &space omega &= omega_n sqrt(1 - xi^2) &space phi &= arccos( xi) $ $ y(0) &= dot(y)(0) = 0 &space dot.double(y)(0) &= mu omega^2_n &space y_( infinity) &= mu k $ $ T_(a,5) & approx frac(3, xi omega_n) &space space T_(a,1) approx frac(4.6, xi omega_n) $ Introduciamo un altro parametro che è la *sovraelongazione percentuale*, definita come $ S % = 100 frac(y_("max") - y_ infinity, y_( infinity)) $ con $y_( T(max))$ valore massimo e $y_( infinity)$ valore asintotico della risposta. Per i sistemi del secondo ordine la sovraelongazione percentuale vale $ S % = 100 e^(- pi xi slash sqrt(1- xi^2)) $ Analizziamo ora la risposta $ y(t) = mu k(1 - A e^(- xi omega_n t) sin( omega t + phi))1(t) $ #cfigure("Images/Sovraelongazione.png", 75%) Dal grafico possiamo evincere che la sovraelongazione percentuale indica di quanto supero il valore stabile prima del transitorio. Come abbiamo visto prima, la sovraelongazione percentuale dipende solo dallo smorzamento, e, se scegliamo un valore massimo di sovraelongazione $S^star$, possiamo ricavare il valore di $ xi$ necessario: $ S % <= S^star <==> xi >= frac( lr(| ln ( dfrac(S^star,100) ) |), sqrt( pi^2 + ln^2 ( dfrac(S^star,100) ))) $ === Luogo di punti a tempo di assestamento costante Adesso proviamo a caratterizzare i sistemi del secondo ordine (con poli complessi coniugati) la cui risposta al gradino ha lo stesso tempo di assestamento. Ricordiamo che - abbiamo approssimato $T_(a,5) approx frac(3, xi omega_n)$ e $T_(a,1) approx frac(4.6, xi omega_n)$ - $- xi omega_n$ è la parte reale dei poli complessi coniugati #cfigure("Images/Secondo_ordine_poli_complessi.png", 50%) Quindi sistemi con poli complessi coniugati che hanno la stessa parte reale avranno una risposta al gradino con stesso tempo di assestamento. Sul piano complesso i luoghi di punti a tempo di assestamento costante sono rette parallele all'asse immaginario. #cfigure("Images/Tempo_assestamento_costante.png", 80%) Nella figura vediamo in verde e in blu due coppie di poli distinti, ma con parte reale uguale; le risposte associate a questi poli sono evidentemente diverse (grafico in blu e grafico in verde), ma hanno lo stesso tempo di assestamento. === Luogo di punti a sovraelongazione costante Proviamo a caratterizzare e i sistemi del secondo ordine (con poli complessi coniugati) la cui risposta al gradino ha la stessa sovraelongazione. Ricordiamo che - $S % = 100 e^( frac(- pi xi, sqrt(1- xi^2)))$ - $ arccos( xi)$ è l'angolo formato con l'asse reale #cfigure("Images/Secondo_ordine_poli_complessi.png", 50%) Quindi sistemi con stesso coefficiente di smorzamento $ xi$ avranno una risposta al gradino con stessa sovraelongazione. Sul piano complesso i luoghi di punti a sovraelongazione costante sono semirette uscenti dall'origine. #cfigure("Images/Sovraelongazione_costante.png", 80%) === Mappatura di specifiche temporali nel piano complesso Vogliamo caratterizzare i sistemi del secondo ordine (con poli complessi coniugati) con $S % <= S^star$ e $T_(a,5) <= T^star$. Le specifiche sono soddisfatte per $ xi >= xi^star$ (con $ xi <= 1$) e $ xi omega_n >= dfrac(3,T^star)$ #cfigure("Images/Specifiche_temporali.png", 75%) i poli complessi coniugati devono trovarsi nella zona colorata. === Sistemi del secondo ordine con poli reali Caso $T_1 != T_2$ e $T_1 > T_2$ $ G(s) &= frac( mu,(1+T_1s)(1+T_2s)) & U(s) &= frac(k,s)\ Y(s) &= G(s)U(s) = frac( mu k,s(1+T_1s)(1+T_2s)) $ $ & mu>0 &space &k>0 &space &T_1>0 &space &T_2>0 $ #cfigure("Images/Secondo_ordine_poli_reali_1.png", 37%) $ y(t) = mu k (1- frac(T_1,T_1-T_2)e^(- frac(t,T_1)) + frac(T_2,T_1-T_2)e^(- frac(t,T_2)) )1(t) $ $ &y(0) = 0 &space &dot(y)(0)=0 & &space dot.double(y)(0) = frac( mu K,T_1 T_2) &space &y_( infinity)= mu k $ #cfigure("Images/Secondo_ordine_poli_reali_2.png", 40%) == Sistemi a polo dominante Consideriamo $T_1 >> T_2$: #align(center)[ #cetz.canvas({ import cetz.draw: * content((1.8, 3.7), [#text(red)[$e^(-t slash T_1) 1(t)$]]) content((1.7, 1.7), [#text(green)[$e^(-t slash T_2)1(t)$]]) plot.plot( size: (8,6), x-tick-step: none, y-tick-step: none, axis-style: "school-book", y-max: 1.5, { plot.add( domain: (0, 20), x => calc.pow(calc.e, -x/15), style: (stroke: red) ) plot.add( domain: (0, 20), x => calc.pow(calc.e, -x/2), style: (stroke: green) ) } ) }) ] Nella risposta $e^(- frac(t,T_2))$ tende a zero velocemente, quindi si può omettere, mentre $dfrac(T_2,T_1-T_2) << dfrac(T_1,T_1 - T_2) approx 1$, quindi $ y(t) approx mu k (1-e^(- frac(t,T_1)) )1(t) $ #cfigure("Images/Polo_dominante.png", 83%) === Esempio con coppia di poli complessi coniugati dominanti $ G(s) = mu frac( omega_n^2,(s^2+2 xi omega_n s + omega_n^2)(s+p)) $ assumiamo $ dfrac(1,T) >> xi omega_n$, cioè $- dfrac(1,T) << - xi omega_n$ #cfigure("Images/Esempio_polo_dominante.png", 70%) Prendiamo $U(s) = dfrac(k,s)$ $ Y(s) &= G(s) U(s)\ &= frac( mu k dfrac(omega_n^2,T),s(s^2+2 xi omega_n s + omega_n^2) (s+ dfrac(1,T) ))\ &= frac(k_1,s) + frac(k_2,s+ xi omega_n+j omega_n sqrt(1- xi^2)) + frac( overline(k_2),s+ xi omega_n-j omega_n sqrt(1- xi^2)) + frac(k_3,s+ dfrac(1,T)) $ Per $ dfrac(1,T) >> xi omega_n$ la risposta si può approssimare a quella di sistemi del secondo ordine $ y(t) approx mu k (1-A e^(- xi omega_n t) sin( omega t + phi) ) $ Quindi, se ho più poli molto distanti dall'asse immaginario, posso sempre approssimare il sistema come un sistema del secondo ordine. Infatti se analizziamo la risposta effettiva del sistema $ y(t) = k_1 1(t) + 2M e^(- xi omega_n t) cos( omega_n sqrt(1 - xi^2)t + phi_k) 1(t) + k_3 e^(-t/T) 1(t) $ il termine $k_3 e^(-t/T) 1(t)$ va a 0 molto velocemente, quindi è trascurabile. == Sistemi del secondo ordine con poli reali coincidenti Caso $T_1=T_2$ $ G(s) &= frac( mu,(1+T_1s)^2) &space U(s) &= frac(k,s) \ Y(s) &= G(s)U(s) = frac( mu k,s(1+T_1 s)^2) $ $ mu>0, k>0, T_1 >0$ $ y(t) = mu k ( 1- e^(-t slash T_1) - frac(t,T_1)e^(-t slash T_1) ) 1(t) $ #cfigure("Images/Poli_reali_coincidenti.png", 40%) I modi presenti sono $1(t)$ (ingresso), $e^(-t slash (T-1))$ e $t e^(-t slash (T-1))$ (sistema). == Sistemi del primo ordine con uno zero $ G(s) &= mu frac(1+ alpha T s,1+T s) & space U(s) &= frac(k,s) \ Y(s) &= G(s) U(s) = mu k frac(1+ alpha T s,s(1+T s)) $ $mu>0, thick k>0, thick T>0$ #cfigure("Images/Primo_ordine_uno_zero_1.png", 30%) $ y(t) &= mu k (1+( alpha-1) e^(-t/T))1(t)\ y(0) &= mu alpha k & space y_( infinity) &= mu k $ #cfigure("Images/Primo_ordine_uno_zero_2.png", 60%) Il grado relativo del sistema è zero, cioè il grado del numeratore è uguale al grado del denominatore; questo implica un collegamento algebrico tra ingresso e uscita, infatti $y(0) != 0$; nello spazio degli stati questo equivale ad avere $D != 0$. == Sistemi del secondo ordine con poli reali e zero === Sistemi a fase non minima $ G(s) &= mu frac(1 + tau s,(1+T_1s)(1+T_2s)) & space U(s) &= frac(k,s) \ Y(s) &= G(s)U(s) = mu k frac(1+ tau s,s(1+T_1s)(1+T_2s)) $ $ mu>0,k>0,T_1>0,T_2>0$ $ y(t) &= mu k ( 1 - frac(T_1- tau,T_1-T_2) e^(-t/T_1) + frac(T_2- tau,T_1-T_2)e^(-t/T_2) )1(t) \ y(0) &= 0 & wide dot(y)(0) &= frac( mu K tau,T_1T_2) & wide y_( infinity) &= mu k $ *N.B.* il segno della derivata $dot(y)(0)$ dipende da $ tau$. Nel caso in cui si abbia $T_1>T_2$ e $ tau<0$ il sistema è detto a *fase non minima*; in generale è detto sistema a *fase minima* un sistema caratterizzato da una funzione di trasferimento $G(s)$ con guadagno positivo, poli e zeri a parte reale negativa o nulla e non contenente ritardi (cioè se non ci sono esponenziali). #figure( grid( columns: (50%, 50%), gutter: 2mm, image("Images/Poli_reali_zero_1.png", width: 70%), image("Images/Poli_reali_zero_2.png",width: 70%) ) ) la sottoelongazione $dot(y)(0)<0$ indica che il sistema inizialmente risponde in senso contrario rispetto all'ingresso. Una bici, o una moto, che sterza è un sistema a fase non minima. Dato un guadagno specifico, esiste #underline[uno e un solo] sistema a fase minima che produce quel guadagno, mentre esistono infiniti sistemi a fase non minima che producono lo stesso. Per più informazioni: #link("https://youtu.be/jGEkmDRsq_M")[What Are Non-Minimum Phase Systems?]. #heading(level: 3, numbering: none)[Domanda] Dato un sistema a fase non minima #tageq($G(s) = mu frac(1 + tau s,(1+T_1 s)(1+T_2 s))$, $ tau < 0$) posso progettare una $R(s) = dfrac(1,1+ tau s)$ tale che $ R(s) G(s) = mu frac(1+ tau s,(1+T_1 s)(1+T_2 s)(1+ tau s)) $ così da eliminare lo zero positivo? \ Ovviamente no, perché $1+ tau s$ è un modello della realtà, quindi, anche se matematicamente si può semplificare, nella realtà non si annullerà mai perfettamente. === Sistemi a fase minima con sovraelongazione Se $ tau>T_1>T_2$ abbiamo un sistema a *fase minima* con una sovraelongazione $ G(s) &= mu frac(1 + tau s,(1+T_1s)(1+T_2s)) & space U(s) &= frac(k,s) \ Y(s) &= G(s)U(s) = mu k frac(1+ tau s,s(1+T_1s)(1+T_2s)) $ $ mu>0,k>0,T_1>0,T_2>0$ #cfigure("Images/Fase_minima_1.png", 40%) $ y(t) &= mu k ( 1 - frac(T_1- tau,T_1-T_2) e^(-t slash (T-1)) + frac(T_2- tau,T_1-T_2)e^(-t slash T_2) )1(t) \ y(0) &= 0 & dot(y)(0) &= frac( mu K tau, T_1T_2) & y_( infinity) &= mu k $ #cfigure("Images/Fase_minima_2.png", 50%) *Nota:* è presente una sovraelongazione tanto più accentuata quanto più lo zero è vicino all'origine (cioè al crescere di $ tau$). === Sistemi a fase minima con code di assestamento Se $ tau approx T_1 >> T_2$ abbiamo un sistema a fase minima con code di assestamento. $ G(s) &= mu frac(1 + tau s,(1+T_1s)(1+T_2s)) & space U(s) &= frac(k,s) \ Y(s) &= G(s)U(s) = mu k frac(1+ tau s,s(1+T_1s)(1+T_2s)) $ $ mu>0, thick k>0, thick T_1>0, thick T_2>0$ #cfigure("Images/Fase_minima_code_ass_1.png", 40%) $ y(t) &= mu k ( 1 - frac(T_1- tau,T_1-T_2) e^(-t/T-1) + frac(T_2- tau,T_1-T_2)e^(-t/T_2))1(t)\ $ $ y(0) &= 0 &wide dot(y)(0) &= frac( mu K tau,T_1T_2) &wide y_( infinity) &= mu k $ #cfigure("Images/Fase_minima_code_ass_2.png", 40%) A causa della non perfetta cancellazione polo/zero ($ tau approx T_1$) il modo "lento" $e^(-t/T_1)$ è presente e il suo transitorio si esaurisce lentamente. = Risposta in frequenza == Risposta a un segnale di ingresso sinusoidale Dato un sistema lineare tempo invariante SISO con funzione di trasferimento $G(s)$ vogliamo calcolare l'uscita in corrispondenza di un ingresso sinusoidale $ u(t) = U cos( omega t + phi) $ la trasformata di Laplace di questo segnale è $ U(s) = U frac(s cos( phi) - omega sin( phi),s^2 + omega^2) $<trasformata_sinusoide> quindi $ Y(s) = G(s) U(s) = G(s) U frac(s cos( phi) - omega sin( phi),s^2 + omega^2) $<risposta_trasformata_sinusoide> Consideriamo $G(s)$ con poli distinti a parte reale negativa (BIBO stabile). Sviluppando in fratti semplici si ha $ Y(s) = sum_(i=1)^n underbrace(frac(k_i,s+p_i),Y_1(s)) + underbrace(frac(k_u,s-j omega) + frac(overline(k)_u,s+j omega),Y_2(s)) $ Eseguiamo lo sviluppo di Heaviside sulla @eqt:trasformata_sinusoide[]: $ Y(s) = G(s) U(s) &= G(s) U frac(s cos( phi) - omega sin( phi),s^2 + omega^2)\ &= frac(N(s)U(s cos( phi) - omega sin( phi)),(s+p_1)(s+p_2) dots (s+p_n)(s^2 + omega^2))\ &= frac(k_1,s+p_1) + frac(k_2,s+p_2) + dots + frac(k_n,s+p_n) + frac(k_u,s-j omega) + frac( overline(k)_u,s+j omega) $ quindi, antitrasformando $ y(t) &= k_1 e^(-p_1t)1(t) + dots k_n e^(-p_n t)1(t) + 2 |k_u| underbrace(e^(- sigma t), sigma = 0) cos ( omega t + arg(k_u))1(t)\ &= underbrace( sum_(i=1)^n k_i e^(-p_i t)1(t),y_1(t)) + underbrace(2 |k_u| cos ( omega t + arg(k_u))1(t),y_2(t)) $ Poiché i poli di $G(s)$ sono a parte reale negativa, i contributi $e^(-p_i t)1(t)$ sono tutti convergenti a zero. Pertanto $y_1(t) arrow 0$ per $t arrow infinity$. Il residuo $k_u$ è dato da $ k_u &= (s - j omega) Y(s) |_(s = j omega)\ &= U G(s) lr(frac(s cos( phi) - omega sin( phi),s+j omega) |)_(s = j omega)\ &= U G(j omega) frac(j omega cos( phi) - omega sin( phi),j omega+j omega)\ &=U G(j omega) frac(j cos( phi) - sin( phi),2j) \ &= U G(j omega) frac( cos( phi) + j sin( phi),2)\ #text(green)[$e^(j phi) = cos( phi)+j sin( phi) ==>$] quad &= U G(j omega) frac(e^(j phi),2)\ &= frac(U|G(j omega)|,2) e^(j ( arg(G(j omega)) + phi)) $ dove abbiamo scritto $G(j omega) = |G(j omega)| e^(j arg(G(j omega)))$. Ora che abbiamo calcolato $k_u$ possiamo sostituirlo nell' espressione di $y(t)$ $ y(t) = y_1(t) + U |G(j omega)| cos( omega t + phi + arg(G(j omega))) $ Siccome $y_1(t) arrow 0$ per $t arrow infinity$, l'uscita $y(t)$ converge a $ y_2(t) = U |G(j omega)| cos ( omega t + phi + arg(G(j omega)) ) $ ovvero, per $t$ sufficientemente grande si ha $ y(t) approx U |G(j omega)| cos( omega t + phi + arg(G(j omega))) $ <risposta_regime_permanente> quest'espressione viene chiamata *risposta a regime permanente* #cfigure("Images/Risposta_regime_perm.png", 75%) === Teorema Se a un sistema lineare tempo invariante con funzione di trasferimento $G(s)$ avente poli a parte reale negativa si applica l'ingresso sinusoidale $ u(t) = U cos( omega t + phi) $ l'uscita, a transitorio esaurito, è data da $ y(t) = U |G(j omega)| cos(omega t + phi + arg(G(j omega))) $ == Risposta a segnali periodici sviluppabili in serie di Fourier Consideriamo un segnale d'ingresso $u(t)$ periodico, cioè $ exists T>0$ tale che $ forall t >= 0 thick u(t+T) = u(t)$, che può essere sviluppato in serie di Fourier $ u(t) = U_0 + 2 sum_(n=1)^(+ infinity) |U_n| cos (n omega_0 t + arg(U_n) ) $ con $omega_0 = dfrac(2 pi,T)$ e #tageq($ U_n = frac(1,T) integral_(t_0)^(t_0+T) u(t) e^(-j n omega_0 t) d t$, $n=0,1,...$) In base a quanto visto per un ingresso sinusoidale e sfruttando il principio di sovrapposizione degli effetti per sistemi BIBO stabili si può dimostrare che per $t$ elevati $ y(t) approx Y_0 + 2 sum_(n=1)^(+ infinity) |Y_n| cos(n omega_0 t + arg(Y_n)) $<risposta_svilupp_Fourier> con $ omega_0 = dfrac(2 pi,T)$ e #tageq($Y_n = G(j n omega_0)U_n$, $n=0,1,...$) Il risultato appena visto può essere schematizzato come segue. Dato in ingresso un segnale periodico, esso può essere rappresentato come la somma delle armoniche dello sviluppo in serie di Fourier #cfigure("Images/Fourier_1.png", 60%) Sfruttando la sovrapposizione degli effetti tale schema è equivalente a considerare lo schema seguente per $t$ elevati #cfigure("Images/Fourier_2.png", 60%) == Risposta a segnali dotati di trasformata di Fourier Dato un segnale non periodico dotato di trasformata di Fourier, possiamo scriverlo come $ u(t) = frac(1,2 pi) integral_(- infinity)^(+ infinity) 2|U(j omega)| cos( omega t + arg(U(j omega))) thick d omega $ con $ U(j omega) = integral_(- infinity)^(+ infinity) u(t) e^(-j omega t) thick d t $ Ovvero l'ingresso è scomponibile come una infinità non numerabile di armoniche con valori di $ omega$ reali maggiori o uguali a zero. Quindi se il sistema è BIBO stabile per $t$ elevati $ y(t) approx frac(1,2 pi) integral_(- infinity)^(+ infinity) 2|Y(j omega)| cos( omega t + arg(Y(j omega))) d omega $<risposta_trasformata_Fourier> con $ Y(j omega) = G(j omega)U(j omega) $ == Richiami === Spettro di un segnale Ogni segnale reale si può ottenere sommando opportune onde sinusoidali #cfigure("Images/Spettro.png", 75%) Uno stesso segnale può essere quindi visto equivalentemente nel dominio del tempo ($y(t)$) o delle frequenze ($Y(j omega)$). Le funzioni $y(t)$ e $Y(j omega)$ sono ugualmente informative e offrono due prospettive complementari per osservare lo stesso fenomeno. La pulsazione $ omega$ e la frequenza $f$ sono legate dalla relazione $ omega = 2 pi f$. == Definizione di Risposta in Frequenza La funzione complessa $G(j omega)$ ottenuta valutando $G(s)$ per $s = j omega$ è detta _risposta in frequenza_. $ G(s) |_(s=j omega) = G(j omega) $ La risposta in frequenza viene estesa anche a sistemi non asintoticamente stabili. Per un certo valore di $ omega$, $G(j omega)$ è un numero complesso #cfigure("Images/Risposta_in_frequenza_1.png", 60%) === Identificazione sperimentale della risposta in frequenza (approccio data-driven) Nel caso in cui la risposta in frequenza non sia nota possiamo sfruttare i risultati precedenti per ricavarla sperimentalmente. #cfigure("Images/Risposta_in_frequenza_2.png", 70%) Diciamo che con questo tipo di approccio riusciamo a stimare la $G(j omega)$ (non la $G(s)$!). == Rappresentazione della risposta in frequenza Vi sono diversi modi di rappresentare la risposta in frequenza. Uno dei modi più usati sono i *diagrammi di Bode*, in cui si rappresentano separatamente $|G(j omega)|$ e $ arg(G(j omega))$ in funzione di $ omega$. Nei diagrammi di Bode si utilizza una scala logaritmica in base dieci per l'ascissa, dove è riportata la pulsazione $ omega$. In particolare, nei diagrammi di Bode si chiama _decade_ l'intervallo tra due pulsazioni che hanno un rapporto tra loro pari a dieci. Per come abbiamo definito i diagrammi, segue che la pulsazione nulla non compare nell'asse "finito" (si può avere pulsazione nulla solo a $- infinity$). Nel tracciamento dei diagrammi di Bode conviene scrivere la funzione $G(s)$ nella forma fattorizzata @eqt:Forma_di_Bode[], qui riportata $ G(s) = frac( mu product_i (1 + tau_i s) product_i (1 + frac(2 zeta_i, alpha_(n i)) + frac(s^2, alpha^2_(n i))), s^g product_i (1 + T_i s) product_i (1 + frac(2 xi_i, omega_(n i)) + frac(s^2, omega^2_(n i)))) $ e la risposta in frequenza associata corrispondente è $ G(j omega) = frac(mu product_i (1 + j omega tau_i) product_i (1 + 2j zeta_i frac( omega, alpha_(n i)) - frac( omega^2, alpha^2_(n i))), (j omega)^g product_i (1 + j omega T_i ) product_i (1 + 2j xi_i frac( omega, omega_(n i)) - frac( omega^2, omega^2_(n i)))) $ Il diagramma delle ampiezze è espresso in *decibel*: $|G(j omega)|_("dB") = 20 log|G(j omega)|$. Il diagramma delle fasi è espresso in gradi: $ arg(G(j omega))$ === Proprietà dei numeri complessi e logaritmi Dati due numeri complessi $a in CC$ e $b in CC$ si ha $ |a b| = |a| |b| $ e $ log(|a||b|) &= log(|a|) + log(|b|) &space arg(a b) &= arg(a) + arg(b) \ log ( frac(|a|,|b|) ) &= log(|a|) - log(|b|) &space arg ( frac(a,b) ) &= arg(a) - arg(b) \ log(|a|^k) &= k log(|a|) &space arg(a^k) &= k arg(a) $ === Esempio operazioni in decibel Definiamo il _modulo in decibel_ di un numero $a$ $ |a|_("dB") = 20 log_(10)|a| $ //log #align(center)[ #cetz.canvas({ import cetz.draw: * content((1.2, 3.5), [$log(x)$], name: "text") plot.plot( size: (6.5,4.5), x-tick-step: none, x-ticks: (1, 0), y-tick-step: none, y-min: -2, y-max: 2, x-min: 0, x-max: 20, axis-style: "school-book", { plot.add( domain: (0.1, 20), x => calc.log(x), style: (stroke: black) ) } ) }) ] inoltre $ |a| >= 1 & ==> |a|_("dB") >= 0 \ 0 <= |a| <= 1 & ==> |a|_("dB") <= 0 $ == Diagrammi di Bode === Diagramma del modulo Partiamo col calcolare il valore del modulo della risposta in frequenza in Decibel $ |G(j omega)|_("dB") = 20 log_(10)|G(j omega)| $ Prendiamo una risposta in frequenza così definita $ G(j omega) = mu frac((1+j omega tau) (1 + 2 frac( zeta, alpha_n)j omega - frac( omega^2, alpha_n^2) ),j omega(1+j omega T) (1 + frac(2 xi, omega_n)j omega - frac( omega^2, omega_n^2) )) $ $ |G(j omega)|_("dB") =& 20 log|G(j omega)| \ =&20 log|mu| + 20 log|1+j omega tau| + 20 log lr(|1+2 frac( zeta, alpha_n)j omega - frac( omega^2, alpha_n^2) |)\ & - 20 log|j omega| - 20 log|1+j omega T| - 20 log lr(|1+ frac(2 xi, omega_n)j omega - frac( omega^2, omega_n^2) |) \ =&|mu|_("dB") + |1 + j omega tau|_("dB") + abs(1+2 frac( zeta, alpha_n)j omega - frac( omega^2, alpha_n^2))_("dB") - |j omega|_("dB")\ & - |1+j omega T|_("dB") - abs(1+ frac(2 xi, omega_n)j omega - frac( omega^2, omega_n^2))_("dB") $ === Diagramma della fase $ arg(G(j omega)) =& arg mu - g arg(j omega) + sum_(i) arg(1+j omega tau_i) + sum_i arg (1 + 2 j zeta_i frac( omega, alpha_(n,1)) - frac( omega^2, alpha^2_(n,i)) ) \ &- sum_(i) arg(1+j omega T_i) - sum_i arg (1 + 2 j xi_i frac( omega, alpha_(n,1)) - frac( omega^2, omega^2_(n,i)) ) $ === Contributi elementari Possiamo quindi studiare l'andamento dei seguenti contributi elementari $ G_a (j omega) &= mu \ G_b (j omega) &= frac(1,(j omega)^g) \ G_c (j omega) &= (1+j omega tau_i) & space G_c (j omega) &= frac(1,1+j omega T_i) \ G_d (j omega) &= ( 1+2j zeta_i frac( omega, alpha_(n,1) )- frac( omega^2, alpha^2_(n,1)) ) & G_d (j omega) &= frac(1, ( 1+2j zeta_i frac( omega, alpha_(n,1) )- frac( omega^2, alpha^2_(n,1)) )) $ La rappresentazione di questi diagrammi avviene su carte logaritmiche che vanno per _decade_, cioè per potenze di dieci. === Guadagno statico $ G_a (j omega) &= mu & space |G_a (j omega)|_("dB") &= 20 log|mu| & space arg(G(j omega)) = arg( mu) $ #cfigure("Images/Diagramma_guadagno_statico_1.png", 63%) Per quanto riguarda il diagramma dell'ampiezza, - se $|mu| >= 1$ allora $20 log|mu| >= 0$ - se $|mu| <1$ allora $20 log|mu| < 0$. Per il diagramma della fase invece - se $ mu >0$ allora $ arg( mu)=0$ - se $ mu <0$ allora $ arg( mu)=-180 degree$. === Zeri nell'origine Consideriamo una risposta con uno zero nell'origine (cioè $g=-1$) $ G_b (j omega) &= frac(1,(j omega)^(-1)) = j omega &wide |G_b (j omega)|_("dB") &= 20 log omega &wide arg(G_b (j omega)) &= arg(j omega) $ #cfigure("Images/Diagramma_zero_origine.png", 72%) La retta che definisce l'ampiezza $ log omega arrow.r.bar 20 log omega$ ha pendenza $20 "dB/dec"$; se ho $g$ zeri nell'origine allora la pendenza della retta sarà $20 dot g "dB/dec"$.\ $j omega$ è un punto sul semiasse immaginario positivo $forall omega > 0$, quindi fase $90^degree forall > 0$. === Poli nell'origine Consideriamo una risposta con un polo nell'origine (cioè $g=1$) $ G_b (j omega) &= frac(1,(j omega)^1) = frac(1,j omega) &space |G_b (j omega)|_("dB") &= -20 log omega &space arg(G_b (j omega)) &= - arg(j omega) $ #cfigure("Images/Diagramma_poli_origine.png", 75%) Anche in questo caso, se ho $g$ poli nell'origine allora la pendenza della retta sarà $-20 "dB/dec"$. Per quanto riguarda la fase $-j omega$ è un punto sul semiasse immaginario negativo $ forall omega>0$, quindi la fase è $-90^ degree$. === Zero reale (ampiezza) Consideriamo una risposta con uno zero reale $ G_c (j omega) = 1 + j omega tau $ $ |G_c (j omega)|_("dB") = 20 log sqrt(1 + omega^2 tau^2) approx cases( 20 log 1 = 0 & omega << dfrac(1,|tau|)\ 20 log omega |tau| = -20 log dfrac(1,|tau|) + 20 log omega wide& omega >> dfrac(1,|tau|) ) $ $ lr(|G_c (j frac(1,|tau|) )|)_("dB") &= 20 log sqrt(1+ frac(1,|tau|^2) tau^2) \ &= 20 log sqrt(2) approx 3 $ per $ omega = frac(1,|tau|)$ abbiamo lo scostamento massimo. #nfigure("Zero_reale_ampiezza.png", 60%) === Zero reale negativo (fase) Consideriamo una una risposta con uno zero reale negativo #tageq($G_c (j omega) = 1 + j omega tau$, $ tau > 0$) $ arg(G_c (j omega)) = arg(1+j omega tau) approx cases( 0 wide& omega << frac(1, tau) \ 90^ degree & omega >> frac(1, tau) ) $ Se $ omega arrow 0$ allora $ arg(1+j omega tau) approx arg(1)=0$ #cfigure("Images/Diagramma_zero_reale_negativo_1.png", 60%) se $ omega >> dfrac(1, tau)$ allora graficamente #cfigure("Images/Diagramma_zero_reale_negativo_2.png", 60%) #cfigure("Images/Diagramma_zero_reale_negativo_3.png", 72%) il cambio di fase inizia circa una decade prima e finisce circa una decade dopo la pulsazione di taglio $ omega = dfrac(1, tau)$. #cfigure("Images/Diagramma_zero_reale_negativo_4.png", 60%) $ dfrac(1,5) dot dfrac(1, tau) = 0.2 dot dfrac(1, tau) = 2 dot 10^(-1) dfrac(1, tau)$, il doppio in scala logaritmica è $ dfrac(1,3)$ di una decade. === Zero reale positivo (fase) Consideriamo $G_c (j omega) = 1 + j omega tau, tau <0$ (cioè una risposta con uno zero reale positivo) #cfigure("Images/Diagramma_zero_reale_positivo_1.png", 32%) $ arg(G(j omega)) = arg(1+j omega tau) approx cases( 0 & omega << frac(1,|tau|) \ -90^( degree) wide& omega >> frac(1,|tau|) ) $ #cfigure("Images/Diagramma_zero_reale_positivo_2.png", 70%) === Polo reale Consideriamo $G_c (j omega) = dfrac(1,1+j omega T)$ (cioè una risposta con un polo reale) $ |G_c (j omega)|_("dB") &= 20 log lr(| frac(1,1+j omega T) |) \ &= -20 log |1+j omega T| $ $ |G_c (j omega)|_("dB") &= -20 log sqrt(1+ omega^2T^2) & space arg(G_c (j omega)) = - arg(1+j omega T) $ #cfigure("Images/Diagramma_polo_reale.png", 73%) Il diagramma è uguale al diagramma dello zero ma ribaltato rispetto all'asse reale (consistentemente con il segno di $T$). === Polo reale negativo Consideriamo $G_c (j omega) = dfrac(1,1+j omega T), T>0$ (cioè una risposta con un polo reale negativo) $ |G_c (j omega)|_("dB") &= -20 log sqrt(1+ omega^2T^2) & space arg(G_c (j omega)) = - arg(1+j omega T) $ #cfigure("Images/Diagramma_polo_reale_negativo_1.png", 53%) Fino a $ dfrac(1,T)$, (pulsazione di taglio), si ha un andamento costante a $0 "dB" $, cioè il modulo della sinusoide in uscita non cambia. A partire da $ dfrac(1,T)$ si ha una retta $ log omega arrow.r.bar 20 log dfrac(1,|T|) - 20 log omega$ con pendenza $-20 "dB/dec"$. Lo scostamento massimo (tra diagramma asintotico e diagramma reale) si ha in $ omega = dfrac(1,T)$ dove $ |G_c (j omega)|_("dB") &= -20 log sqrt(1+1) \ &= -20 log sqrt(2) approx -3 $ Il cambio di fase inizia circa una decade prima e finisce circa una decade dopo la pulsazione di taglio $ omega = dfrac(1,T)$. === Zeri complessi coniugati (ampiezza) Consideriamo $G_d (j omega) = 1+ 2j zeta dfrac( omega, alpha_n) - dfrac( omega^2, alpha_n^2)$, una risposta con una coppia di zeri complessi coniugati $ |G_d (j omega)|_("dB") = 20 log sqrt( (1 - frac( omega^2, alpha_n^2) )^2 + 4 zeta^2 frac( omega^2, alpha_n^2)) $ per $ omega >> alpha_n$ $ |G_d (j omega)|_("dB") & approx 20 log sqrt( ( frac( omega^2, alpha_n^2) )^2) \ &=20 log frac( omega^2, alpha_n^2) \ &= 20 log ( frac( omega, alpha_n) )^2 \ &= 40 log frac( omega, alpha_n) \ &= underbrace(40 log omega, "variabile") - underbrace(40 log alpha_n, "costante") $ Quindi la risposta si comporta come una retta, di pendenza pari a 40 dB. Analizziamo ora la risposta per $ omega = alpha_n$ $ |G_d (j omega)|_("dB") &20 log sqrt( (1 - frac( omega^2, alpha_n^2) )^2 + 4 zeta^2 frac( omega^2, alpha_n^2)) \ &= 20 log sqrt(4 zeta^2) \ &= 23 log 2|zeta| \ &= underbrace(20 log 2 ,6 "dB") +20 log |zeta| $ quindi scostamento significativo dipendente dal valore di $ zeta$. $ |G_d (j omega)|_("dB") = 20 log sqrt( (1 - frac( omega^2, alpha_n^2) )^2 + 4 zeta^2 frac( omega^2, alpha_n^2)) approx cases( 20 log(1) = 0 & omega << alpha_n \ 20 log dfrac( omega^2, alpha_n^2) = -40 log alpha_n + 40 log omega wide& omega >> alpha_n ) $ #cfigure("Images/Diagramma_zeri_cc_ampiezza_1.png", 55%) #cfigure("Images/Diagramma_zeri_cc_ampiezza_2.png", 55%) Il minimo dell'ampiezza si ha alla pulsazione $ omega_r = alpha_n sqrt(1-2 zeta^2)$ con $|G_d (j omega_r)| = 2 |zeta| sqrt(1- zeta^2)$ === Zeri complessi coniugati a parte reale negativa (fase) Consideriamo $G_d (j omega) = 1+ 2j zeta dfrac( omega, alpha_n) - dfrac( omega^2, alpha_n^2), zeta>0$, una risposta con una coppia di zeri complessi coniugati a parte reale negativa $ arg(G_d (j omega)) approx cases( 0 & omega << alpha_n \ 180^ degree wide& omega >> alpha_n ) $ #cfigure("Images/Diagramma_zeri_cc_neg_1.png", 60%) Vediamo che la risposta, per $ omega >> alpha_n$, nel piano complesso ha sicuramente una parte reale molto negativa, mentre la parte immaginaria dipende dal valore $ zeta$, il quale influenza molto l'andamento della fase. Ad esempio se $ zeta arrow 0$ la parte immaginaria nel piano complesso tenderà anch'essa a 0, così da rendere molto facile appurare che l'argomento della nostra risposta sia quasi $180^ degree$. Anche con $ zeta =1$ l'argomento sarà circa $180^ degree$, ma solo per pulsazioni molto grandi, perché la parte reale tende a $ dfrac( omega^2, alpha_n^2)$, che è $O( dfrac( omega, alpha_n))$ (la parte immaginaria) per $ omega arrow infinity$. #cfigure("Images/Diagramma_zeri_cc_neg_2.png", 73%) Nel diagramma di fase più $ zeta$ è piccolo e più la discontinuità da $0^ degree$ a $180^ degree$ è rapida. === Zeri complessi coniugati a parte reale positiva Consideriamo $G_d (j omega) = 1+ 2j zeta dfrac( omega, alpha_n) - dfrac( omega^2, alpha_n^2), quad zeta < 0$, una risposta con una coppia di zeri complessi coniugati a parte reale positiva. Il diagramma di fase di è speculare a quello precedente #cfigure("Images/Diagramma_zeri_cc_pos_1.png", 73%) === Poli complessi coniugati a parte reale negativa <poli_complessi_coniugati_parte_reale_negativa> Consideriamo una risposta in frequenza con poli complessi coniugati a parte reale negativa $G_d (j omega) = dfrac(1,1+2j xi frac( omega, omega_n)- frac( omega^2, omega_n^2)), xi > 0$ #cfigure("Images/Diagramma_poli_cc_neg_1.png", 63%) I diagrammi sono quelli precedenti ribaltati rispetto all'asse reale, infatti la retta del diagramma di ampiezza asintotico dopo la pulsazione $ omega_n$ ha pendenza $-40$ dB/dec. Il picco di risonanza si trova alla pulsazione (di risonanza) $ omega_r = omega_n sqrt(1-2 xi^2)$ con $|G_d (j omega_r)| = dfrac(1,2|xi| sqrt(1-2 xi^2))$; alla frequenza $ omega_n$ si ha $|G_d (j omega_n)| = dfrac(1,2|xi|)$ Soffermiamoci un attimo sul caso in cui $ xi arrow 0$: se do una sinusoide con frequenza inferiore a $ omega_n$ essa non viene sfasata; se invece la sua frequenza è di poco superiore a $ omega_n$ la sua fase viene sfasata di $90^ degree$; il modulo viene amplificato di molto se la frequenza della sinusoide è nell'intorno di $ omega_n$. === Poli complessi coniugati a parte reale positiva Consideriamo una risposta in frequenza con una coppia di poli complessi coniugati a parte reale positiva #tageq($G_d (j omega) = frac(1,1+2j xi frac( omega, omega_n) - frac( omega^2, omega_n^2))$, $ xi < 0$) Calcoliamo i poli $ G_d (s) =& frac(1,1+2 frac( xi, omega_n)s + frac(s^2, omega_n^2)) \ =& frac( omega_n^2,s^2+2 xi omega_n s + omega_n^2) \ ==>& p_(1 slash 2) = - xi omega_n plus.minus j omega_n sqrt(1 - xi^2) $ #cfigure("Images/Diagramma_poli_cc_pos.png", 68%) Diagramma ottenuto da quello degli zeri (caso $ zeta<0$) ribaltando rispetto all'asse reale. === Ritardo temporale Consideriamo $G(s) = e^(- tau s)$ con $G(j omega) = e^(-j omega tau )$ $ |G(j omega)|_("dB") &= 20 log |e^(-j omega tau)| \ &= 20 log 1 \ &=0 $ $ arg(G(j omega)) &= arg(e^(-j omega tau)) \ &= - omega tau $ Questo tipo di sistema ritarda di $ tau$ il segnale in ingresso, quindi la fase viene attenuata mentre il modulo rimane invariato. #cfigure("Images/Diagramma_rit_temp.png", 60%) === Proprietà bloccante degli zeri Supponiamo di avere $G(s) = mu dfrac(s^2+ alpha_n^2,(1+T_1 s)(1+T_2 s))$, con $T_1,T_2 > 0$ (quindi abbiamo un sistema asintoticamente stabile). Calcoliamo l'uscita del sistema supponendo un ingresso del tipo $u(t) = U cos(omega_u t) $. La trasformata dell'ingresso è $U(s) = dfrac(U s,s^2 + omega_u^2)$ - Caso 1: $ omega_u != alpha_n$.\ La trasformata dell'uscita sarà uguale a $ Y(s) = G(s) U(s) = mu frac(U s (s^2+ alpha_n^2),(1+T_1 s)(1+T_2 s)(s^2 + omega_u^2)) $ In base al denominatore, i modi presenti nell'uscita sono: #list(marker: [-], [$e^(-t slash T_1)$ dovuto al termine $1+T_1 s$], [$e^(-t slash T_2)$ dovuto al termine $1+T_2 s$], [$|G(j omega_u)|U cos( omega_u t + arg(G(j omega_u)))$ dovuto al termine $s^2+ omega_u^2$] ) - Caso 2: $ omega_u = alpha_n$.\ La trasformata dell'uscita sarà uguale a $ Y(s) = G(s) U(s) = mu frac(U s cancel((s^2+ alpha_n^2)),(1+T_1 s)(1+T_2 s) cancel((s^2 + alpha_n^2))) = mu frac(U s,(1+T_1 s)(1+T_2 s)) $ In base al denominatore, i modi presenti nell'uscita sono: #list(marker: [-], [$e^(-t slash T_1)$ dovuto al termine $1+T_1 s$], [$e^(-t slash T_2)$ dovuto al termine $1+T_2 s$] ) Pertanto nell'uscita $y(t) = k_1 e^(-t slash T_1) + k_2 e^(-t slash T_2)$ non sono presenti i modi corrispondenti agli zeri del sistema. == Risonanza Supponiamo di avere un sistema con poli immaginari coniugati $ plus.minus j omega_n$, ovvero $G(s) = mu dfrac( omega_n^2,s^2+ omega_n^2)$ (rispetto al caso generale qui $ xi = 0$); il diagramma di Bode ha un picco di risonanza infinito alla pulsazione $ omega_n$. Analizziamone il significato calcolando l'uscita del sistema in corrispondenza dell'ingresso $u(t) = U cos( omega_u t)$. La trasformata dell'ingresso è $U(s) = U dfrac(s,s^2+ omega_u^2)$, quindi quella dell'uscita è $ Y(s) = G(s)U(s) = mu frac(U omega_n^2 s,(s^2 + omega_n^2)(s^2 + omega_u^2)) $ #set enum(numbering: "1)") + $ omega_u != omega_n$ $ Y(s) = frac(k_1,s-j omega_n) + frac( overline(k)_1,s+j omega_n) + frac(k_2,s-j omega_u) + frac( overline(k)_2,s+j omega_u) $ $ y(t) = 2 |k_1| cos( omega_n t + arg(k_1)) + 2|k_2| cos( omega_u t + arg(k_2)) $ l'uscita è la somma di due sinusoidi a frequenza $ omega_n$ e $ omega_u$ + $ omega_u = omega_n$ $ Y(s) &= G(s) U(s) \ &= mu U frac(s omega_n^2,(s^2+ omega_n^2)(s^2+ omega_n^2)) \ &= mu U frac(s omega_n^2,(s^2+ omega_n^2)^2) \ &= frac(k_1,s-j omega_n) + frac( overline(k)_1,s+j omega_n) + frac(k_2,(s-j omega_n)^2) + frac( overline(k)_2,(s+j omega_n)^2) $ $ y(t) = 2 |k_1| cos( omega_n t + arg(k_1)) + 2|k_2| cos( omega_n t + arg(k_2)) $ L'uscita tende a infinito per $t arrow infinity$, quindi il sistema non è BIBO stabile; questo fenomeno viene chiamato *risonanza*. #cfigure("Images/Risonanza.png", 35%) == Azione filtrante dei sistemi dinamici Quanto visto mostra come un sistema dinamico lineare e stazionario si comporta sostanzialmente come un _filtro_ per l'ingresso, modellandolo per produrre l'uscita. === Filtro passa-basso Un filtro ideale passa-basso è un sistema che lascia passare inalterata, o amplificate di un valore costante, unicamente le armoniche del segnale di ingresso con pulsazione inferiore o uguale a un dato valore $ overline( omega)$; il diagramma di Bode del filtro è costante dino a $ overline( omega)$ e vale $- infinity$ "dB" per $ omega > overline( omega)$, mentre il diagramma della fase è nullo fino a $ overline( omega)$. La realizzazione di un filtro ideale passa-basso è di fatto impossibile, quindi definiamo un filtro reale passa-basso come un sistema con $G(j omega)$ che soddisfa le seguenti relazioni $ cases( dfrac(1, sqrt(2)) <= dfrac(|G(j omega)|,|G(j 0)|) <= sqrt(2) wide& omega <= overline( omega) \ \ dfrac(|G(j omega)|,|G(j 0)|) < dfrac(1, sqrt(2)) & omega> overline( omega) ) $<passa_basso> #cfigure("Images/Passa_basso.png", 70%) N.B. Nella @eqt:passa_basso[] lo sfasamento introdotto da $G(s)$ non ha alcun ruolo, mentre il contributo di fase di un filtro #underline[reale] può essere significativo e non va trascurato. === Filtro passa-alto Un _filtro ideale passa-alto_ è un sistema che lascia passare inalterate, o amplificate di una quantità costante, unicamente le armoniche del segnale di ingresso con pulsazione maggiore o uguale a $ tilde( omega)$. Un _filtro reale passa-alto_ è un sistema caratterizzato da una risposta in frequenza $G(j omega)$ il cui modulo soddisfa le seguenti relazioni $ cases( dfrac(|G(j omega)|,|G(j 0)|) < dfrac(1, sqrt(2)) & omega< tilde( omega) \ \ dfrac(1, sqrt(2)) <= dfrac(|G(j omega)|,|G(j 0)|) <= sqrt(2) wide& omega >= tilde( omega) ) $<passa_alto> #cfigure("Images/Passa_alto.png", 70%) Solo sistemi non strettamente propri possono avere le caratteristiche di un filtro passa-alto, dato che la @eqt:passa_alto[] implica che $G(j infinity) != 0$. === Passa banda I _filtri passa banda ideali_ sono sistemi che lasciano passare solo armoniche del segnali in ingresso comprese tra $ omega_(B 1)$ e $ omega_(B 2)$. I _filtri passa banda reali_ sono sistemi che hanno una $G(j omega)$ che soddisfa le seguenti relazioni $ cases( dfrac(1, sqrt(2)) <= dfrac(|G(j omega)|,|G(j omega_(max))|) <= sqrt(2) wide& omega in [ omega_(B 1), omega_(B 2)] \ \ dfrac(|G(j omega)|,|G(j omega_(max))|) < dfrac(1, sqrt(2)) & omega in [0, omega_(B 1)] union [ omega_(B 2), 0] ) $<passa_banda> #cfigure("Images/Passa_banda.png", 53%) === Elimina banda I _filtri elimina banda ideali_ sono sistemi che non lasciano passare solo armoniche del segnali in ingresso comprese tra $ omega_(B 1)$ e $ omega_(B 2)$. I _filtri elimina banda reali_ sono sistemi che hanno una $G(j omega)$ che soddisfano le seguenti relazioni $ cases( dfrac(1, sqrt(2)) <= dfrac(|G(j omega)|,|G(j omega_(max))|) <= sqrt(2) wide& omega in [0, omega_(B 1)] union [ omega_(B 2), 0] \ \ dfrac(|G(j omega)|,|G(j omega_(max))|) < dfrac(1, sqrt(2)) & omega in [ omega_(B 1), omega_(B 2)] ) $ #cfigure("Images/Elimina_banda.png", 53%) == Esempio diagramma di Bode Prendiamo una risposta in frequenza $ G(s) = 10 dot frac(1 + 0.1 s,1+10 s) $ Il guadagno è $ mu = 10$, che in decibel è $ 20 log mu &= 20 log 10 \ &= 20 "dB" $ C'è uno zero $ 1+10^(-1)s & xarrow(width: #2em, "") s_z = -10 &space omega_z &= 10 $ e un polo $ 1+10 s & xarrow(width: #2em, "") s_p = -10^(-1) & space omega_p &= 10^(-1) $ $ G(j omega) = 10 dot frac(1 + 10^(-1)j omega,1 + 10 j omega) $ Il diagramma d'ampiezza risultante può essere visto come la somma dei contributi del polo e dello zero (in #text(green)[verde] il contributo dello zero, in #text(red)[rosso] il contributo dell polo, in #text(blue)[blu] la somma) #cfigure("Images/Esempio_diagramma_amp.png", 60%) #cfigure("Images/Esempio_diagramma_fase.png", 60%) Per quanto riguarda il diagramma di fase, $-90^degree$ è un valore asintotico che si può raggiungere solo per $ omega arrow infinity$, quindi non sarà mai raggiunto in un sistema reale; inoltre la presenza di uno zero aumenta la fase nel diagramma. === Filtrare un'onda quadra con disturbo in alta frequenza Consideriamo un segnale $s(t)$ ad onda quadra con periodo $T$ e ampiezza $A$: $ s(t) = A "sign" (sin(frac(2 pi t,T) ) ) = cases( A & "se" sin ( dfrac(2 pi t,T) ) >= 0 \ -A wide& "se" sin ( dfrac(2 pi t,T) ) < 0 ) $ #cfigure("Images/Filtro_onda_quadra.png", 42%) Supponiamo che l'ingresso consista nell'onda quadra più un disturbo sinusoidale ad alta frequenza $ omega_N >> dfrac(2 pi,T)$ con ampiezza $A_N$ $ u(t) = s(t) + A_N sin( omega_N t) $ Per filtrare il disturbo in alta frequenza possiamo usare un filtro passa-basso, cioè un sistema dinamico del primo ordine con un polo reale in $- dfrac(1,T_p)$: $G(s) = dfrac(1,1+s T_p)$. Scegliendo opportunamente la costante di tempo $T_p$ il segnale in uscita sarà una versione filtrata dell'onda quadra con disturbo in alta frequenza quasi completamente attenuato. = Sistemi di controllo: stabilità e prestazioni == Schema di controllo in retroazione Consideriamo il seguente schema di controllo in retroazione #cfigure("Images/Retroazione_1.png", 60%) Ci poniamo come obiettivo quello di garantire che l'uscita $y(t)$ segua il riferimento $w(t)$ (scelto dall'utente) in presenza di - disturbi (non misurabili) in uscita $d(t)$ e disturbi di misura $n(t)$ - incertezze sul modello $G(s)$ del sistema fisico (impianto) considerato soddisfacendo opportune specifiche di prestazione. Definiamo $ L(s) = R(s) G(s) $<funzione_anello> come *funzione d'anello*, cioè la funzione di trasferimento in anello aperto del sistema.\ $R(s)$ è chiamato *regolatore*. === Sistema in anello chiuso Prendiamo un sistema in retroazione in anello chiuso (caso ideale senza rumore o disturbi) #cfigure("Images/Retroazione_anello_chiuso.png", 65%) *N.B.* Chiameremo sempre la $w(t)$ come uscita di riferimento $y_("RIF")(t)$; quindi $y_("RIF")(t)$ è quello che voglio ottenere dal sistema, mentre $y(t)$ è come si comporta il sistema. $ Y(s) = F(s) underbrace(Y_("RIF")(s),W(s)) $<relazione_ingresso_riferimento-uscita> è ovvio che se potessimo decidere il valore di $F(s)$ sarebbe 1. == Schema generale e semplificazione Lo schema del sistema in retroazione ad anello aperto cattura anche strutture più complesse che includono attuatori e trasduttori #cfigure("Images/Schema_generale_retro.png", 60%) *N.B.* Il riferimento $w$ viene filtrato con una replica della dinamica del sensore $T(s)$ in modo che sia "compatibile" con la dinamica dell'uscita $y$ retroazionata. Usando le proprietà di schemi a blocchi interconnessi, si può riscrivere lo schema precedente in modo equivalente. #cfigure("Images/Schema_gen_rielaborato.png", 60%) Così lo schema diventa #cfigure("Images/Schema_gen_semp.png", 60%) - Sistemi: $R(s) = T(s) tilde(R)(s), G(s) = A(s) tilde(G)(s)$ - Segnali: $W(s) = tilde(W)(s), N(s) = T^(-1)(s) tilde(N)(s), D(s) = D_a (s) tilde(G)(s) + D_u(s)$ il disturbo sull'attuatore $d_a (t)$ viene filtrato dal sistema. Bisogna tenerne conto quando si fanno considerazioni sul disturbo in uscita $d(t)$. $R(s)$ è la funzione di trasferimento del regolatore e $G(s)$ del sistema sotto controllo; inoltre assumiamo che $R(s)$ e $G(s)$ siano funzioni razionali, con $G(s)$ strettamente propria, mentre $R(s)$ può essere rappresentativa di sistemi non strettamente propri e non dinamici. La funzione ad anello $L(s) = R(s)G(s)$ risulta sempre strettamente propria. == Disaccoppiamento frequenziale dei segnali Nelle applicazioni di interesse ingegneristico tipicamente le bande dei segnali di ingresso $w(t), d(t), n(t)$ sono limitate in opportuni range. #cfigure("Images/Disacc_freq_segnali.png", 60%) - $w(t), d(t)$ hanno bande a "basse frequenze", ad esempio posizioni, rotazioni, velocità, etc ... di sistemi meccanici - $n(t)$ ha bande ad "alte frequenze", ad esempio disturbi termici in componenti elettronici, accoppiamenti con campi elettromagnetici, etc ... Lo stesso vale per le trasformate: $W(j omega), D(j omega)$ hanno valori non nulli a "basse frequenze", mentre $N(j omega)$ ha valori non nulli ad "alte frequenze". == Requisiti di un sistema di controllo === Stabilità *Stabilità in condizioni nominali* Il requisito fondamentale per il sistema in retroazione che stiamo considerando è l'asintotica stabilità (@Stabilità_interna[]) o stabilità BIBO (@BIBO[]). *Stabilità robusta* La stabilità deve essere garantita anche in condizioni perturbate (errori di modello o incertezze nei parametri), perché la $G(s)$ rappresenta soltanto un modello approssimato del sistema sotto controllo. === Prestazioni Oltre alla stabilità, è necessario che il sistema abbia determinate prestazioni, cioè che abbia le proprietà elencate. *Prestazioni statiche in condizioni nominali* Il sistema ha un errore $e$ limitato o nullo per $t arrow infinity$, cioè dopo che si è esaurito il transitorio iniziale, a fronte di ingressi $w, d, n$ con determinate caratteristiche. Esempi: - errore in risposta a un ingresso a gradino (transizione ad un nuovo riferimento o disturbi costanti su attuatori/sensori) o rampa; - risposta a un ingresso sinusoidale a date frequenze (disturbi con certe componenti frequenziali) *Prestazioni dinamiche in condizioni nominali* Prestazioni del sistema in transitorio relative a - risposta a un riferimento $w$, data in termini di tempo di assestamento $T_(a, epsilon)$ e sovraelongazione $S %$ massimi; - risposta a disturbi $d$ e $n$, data in termini di attenuazione in certi range di frequenze (bande di frequenza dei disturbi); - moderazione della variabile di controllo $u$, data in termini di contenimento dell'ampiezza (per evitare saturazione di attuatori, uscita da range in cui la linearizzazione è valida o costi eccessivi). === Stabilità robusta del sistema retroazionato (Criterio di Bode) Poiché la stabilità di un sistema lineare non dipende dagli ingressi, consideriamo il seguente schema a blocchi #cfigure("Images/Stabilita_robusta.png", 60%) Per studiare la stabilità robusta, in presenza di incertezze, del sistema retroazionato ci baseremo su un principio fondamentale: il *Criterio di Bode*, che lega la stabilità del sistema retroazionato a quella del sistema in anello aperto. $ F(s) &= frac(Y(s),W(s)) ==> Y(s) = F(s) W(s) $ Tenendo conto che, logicamente, l'errore del sistema $e(t)$ è la differenza tra il l'uscita di riferimento $y_("RIF") (t)$ e l'uscita reale $y(t)$ $ Y(s) &= R(s) G(s) overbrace(E(s), cal(L)[e(t)]) \ &=R(s)G(s) (W(s) - Y(s) ) \ &= R(s)G(s) W(s) - R(s) G(s)Y(s) $ Riarrangiamo i termini $ Y(s) + R(s)G(s)Y(s) &= R(s)G(s)W(s) \ (1+R(s)G(s) )Y(s) &= R(s)G(s)W(s) $ quindi $ Y(s) = underbrace( frac(R(s)G(s),1+R(s)G(s)),F(s)) W(s) $ $ cases(reverse: #true, F(s) = dfrac(R(s)G(s),1+R(s)G(s)) \ L(s) = R(s)G(s) ) ==> F(s) = frac(L(s),1+L(s)) $ == Margini di fase e ampiezza === Margine di fase In un sistema ad anello chiuso la funzione di trasferimento è $dfrac(L(s), 1+L(s))$. Sappiamo che un sistema è instabile se la funzione di trasferimento va a $infinity$; quindi nel nostro caso $ frac(L(s), 1+L(s)) = infinity <==> 1+L(s) = 0 <==> L(s) = -1 $ La funzione $L(s) = -1$ rappresenta un guadagno del sistema pari a 1, o 0 dB, e una fase di $-180 degree$ (riproduce l'input ribaltato). Per questo se nel diagramma di Bode di un sistema, in corrispondenza dello 0 dB del diagramma delle ampiezze, il diagramma di fase vale $-180 degree$ il sistema è instabile.\ Il margine di fase quindi, esprime quanto siamo lontani dall'instabilità, ed è definito come $ M_f = 180^( degree) + arg(L(j omega_c)) "con" omega_c "tale che" |L(j omega_c)|_("dB") = 0 $<margine_fase> Nota: $M_f = arg(L(j omega_c)) - (-180^( degree)) = 180^( degree) + arg(L(j omega_c))$. La seguente figura (e questa risorsa: #link("https://youtu.be/ThoA4amCAX4")[Gain and Phase Margins Explained]) può aiutare a comprendere meglio cos'è il margine di fase (in figura il margine di fase è indicato con $ phi_m$) #cfigure("Images/Margine_fase.png", 65%) Il margine di fase indica il ritardo massimo che può essere introdotto nel sistema mantenendolo stabile. Consideriamo un sistema che ritarda il suo input di $ tau$, che quindi ha funzione di trasferimento $e^(-s tau)$. Il suo diagramma di Bode delle ampiezze è costante a 0 dB. Lo sfasamento è $- omega tau$, che nel diagramma di Bode delle fasi, in scala semi-logaritmica, ha un andamento di tipo esponenziale. Se $L(s) = e^(-s tau) tilde(L)(s)$ la pulsazione critica $ omega_c$ non cambia, è la stessa per entrambe. Un ritardo quindi riduce il margine di fase in quanto, per $ omega = omega_c$, riduce la fase: $ arg(L(j omega_c)) = arg ( tilde(L)(j omega_c) ) - tau omega_c $ quindi per essere asintoticamente stabile, un sistema deve poter tollerare un ritardo $ tau$ che soddisfi la disequazione $ tau < frac(M_f, omega_c) $ #cfigure("Images/Margine_fase_2.png", 90%) === Margine di ampiezza La definizione di margine di ampiezza parte dallo stesso assunto del margine di fase, solo che in questo caso prendiamo come riferimento la frequenza alla quale il diagramma delle fasi ha valore $-180 degree$. Infatti anch'esso ci da una misura di quanto siamo distanti dall'instabilità. #align(center)[$M_a = -|L(j omega_( pi))|_("dB")$ con $ omega_( pi)$ tale che $ arg(L(j omega_( pi))) = -180^( degree)$] La seguente figura può aiutare a comprendere meglio cos'è il margine di ampiezza (in figura il margine di ampiezza è indicato con $|k_m|_("dB")$) #cfigure("Images/Margine_ampiezza.png", 60%) Il margine di ampiezza indica il guadagno massimo che può essere introdotto mantenendo il sistema asintoticamente stabile. Supponendo di introdurre un ulteriore guadagno $k$ nel sistema, esso rimane asintoticamente stabile per tutti i valori di $k$ inferiori a $M_a$. #cfigure("Images/Margine_ampiezza_2.png", 90%) === Casi patologici Ci sono casi in cui $M_f$ e $M_a$ non sono definiti o non sono informativi: - nel caso di *intersezioni multiple*, in cui il diagramma delle ampiezze attraversa l'asse a 0 dB più di una volta; - nel caso di *assenza di intersezioni*, in cui il diagramma delle ampiezze non attraversa mai l'asse a 0 dB; - nel caso di margini di ampiezza e fase con *segni discordi*, perché per essere informativi $M_f$ e $M_a$ devono avere lo stesso segno. == Criterio di Bode Si supponga che + $L(s)$ non abbia poli a parte reale (strettamente) positiva + il diagramma di Bode del modulo di $L(j omega)$ attraversi una sola volta l'asse a 0 dB. Allora, condizione necessaria e sufficiente perché il sistema retroazionato sia asintoticamente stabile è che risulti $ mu > 0$ (con $ mu$ guadagno statico di $L(j omega)$) e $M_f > 0$. In questo modo quindi la stabilità del sistema in retroazione è determinata dalla lettura di un solo punto sul diagramma di Bode di $L(j omega)$. Si rammenta che $M_f$ e $M_a$ in genere vanno considerati simultaneamente e forniscono una misura della robustezza rispetto a incertezze su $L(s)$. #pagebreak() == Funzioni di sensitività #cfigure("Images/Schema_gen_semp.png", 65%) Ingressi del sistema in anello chiuso: - $w(t)$ riferimento (andamento desiderato per $y(t)$) - $d(t)$ disturbo in uscita - $n(t)$ disturbo di misura Uscite di interesse: - $e(t) = w(t) - y(t)$ errore di inseguimento - $y(t)$ uscita controllata - $u(t)$ ingresso di controllo del sistema in anello aperto (impianto) Definiamo le _funzioni di sensitività_ come funzioni di trasferimento tra ingressi e uscite di interesse. $ cases( S(s) = dfrac(1,1+R(s)G(s)) & "Funzione di sensitività" \ \ F(s) = dfrac(R(s)G(s),1+R(s)G(s)) & "Funzione di sensitività complementare" \ \ Q(s) = dfrac(R(s),1+R(s)G(s)) wide& "Funzione di sensitività del controllo" ) $<funzioni_sensitivita> $ mat(delim: "[", Y(s) ; U(s) ; E(s) ) = mat(delim: "[", F(s) , S(s) , -F(s); Q(s) , -Q(s) , -Q(s) ; S(s) , -S(s) , F(s) ) mat(delim: "[", W(s) ; D(s) ; N(s) ) $ #cfigure("Images/Funzioni_sens.png", 60%) Definiamo $y_w (t)$ l'uscita con ingresso $w(t)$, $y_d (t)$ l'uscita con ingresso $d(t)$ e $y_n (t)$ l'uscita con ingresso $n(t)$; per il principio di sovrapposizione degli effetti $ y(t) = y_w (t) + y_d (t) + y_n (t) $ === Funzione di sensitività complementare Prendiamo in considerazione solo l'ingresso $w(t)$. Sappiamo dalla @eqt:relazione_ingresso_riferimento-uscita[] che la funzione di trasferimento che lega $Y_w (s)$ e $W(s)$ è $F(s)$ $ Y_w (s) = F(s) W(s) $ e sappiamo che la $F(s)$ è così definita $ F(s) = frac(R(s)G(s),1+R(s)G(s)) := "Funzione di sensitività complementare" $<funzione_sensitivita_complementare> === Funzione di sensitività Prendiamo in considerazione solo l'ingresso $d(t)$. #cfigure("Images/Funzione_di_sensitività.png", 65%) $ Y_d (s) &= underbrace(D(s), cal(L)[d(t)]) + R(s) G(s) underbrace(E_d (s), cal(L)[e(t)]) \ &= D(s) + R(s) G(s) (0 - Y_d (s) ) wide& #text(green)[$ <== E_d (s) = underbrace(Y_w (s),0) - Y_d (s) $] $ riarrangiamo i termini $ Y_d (s) + R(s) G(s) Y_d (s) &= D(s) \ (1+R(s) G(s) ) Y_d (s) &= D(s) $ quindi $ Y_d (s) = frac(1,1+R(s) G(s))D(s) $ $ S(s) = frac(1,1+R(s) G(s)) := "Funzione di sensitività" $<funzione_sensitivita> siccome $L(s) = R(s) G(s)$ la funzione di sensitività può essere scritta come $ S(s) = frac(1,1+L(s)) $<funzione_sensitivita_2> === Funzione di sensitività del controllo Prendiamo in considerazione solo l'ingresso $n(t)$. #cfigure("Images/Funzione_di_sensitività_controllo.png", 65%) $ Y_n (s) &= F(s) (-N(s) ) \ &=-F(s)N(s) $ === Considerazioni *Stabilità* Il denominatore di tutte le funzioni di sensitività è lo stesso. Si ricordi che la stabilità è determinata dai poli della funzione di trasferimento. Questo è consistente con il fatto che la stabilità del sistema (retroazionato) non dipende dal particolare ingresso considerato. $ Y(s) &= Y_w (s) + Y_d (s) + Y_n (s) \ &= F(s)W(s) + S(s)D(s) - F(s)N(s) $ Per seguire fedelmente il riferimento $w(t)$ vorremmo $F(s) = 1$, che è il caso ideale $ Y_n (s) &= -N(s) &space space S(s) &= frac(1,1+L(s)) $ e per annullare l'effetto del disturbo $d(t)$ vorremmo $S(s) = 0$. Tuttavia il disturbo $n(t)$ non sarebbe per niente attenuato. Inoltre $S(s)+F(s) = 1$ sempre $ S(s)+F(s) &= frac(1,1+L(s)) + frac(L(s),1+L(s)) \ &= 1 $ è il motivo per cui $F(s)$ viene chiamata funzione di sensitività complementare. Noi lavoreremo in frequenze in modo da avere, per $F(j omega) = dfrac(L(j omega),1+L(j omega))$ - $|F(j omega)| approx 1$ a "basse" frequenze (inseguimento di $w(t)$) - $|F(j omega)| approx 0$ ad "alte" frequenze (abbattimento di $n(t)$) Quindi progettermo $R(j omega)$ in mode che - $|L(j omega)| >> 1$ a basse frequenze - $|L(j omega)| << 1$ ad alte frequenze Ricordando che - $w(t), d(t)$ hanno componenti frequenziali a "basse" frequenze - $n(t)$ ha componenti frequenziali ad "alte" frequenze === Errori $ E_w (s) &= W(s) - Y_w (s) & E_d (s) &= W(s) - Y_d (s) space& E_n (s) &= W(s) - Y_n (s) \ &= W(s) - F(s)W(s) & &= 0 - Y_d (s) & &= 0 - Y_n (s) \ &= (1-F(s) ) W(s) & &= -Y_d (s) & &= -Y_n (s) \ #text(fill: green, size: 8pt, baseline: -1pt)[$S(s) = 1 - F(s) ==>$]&= S(s) W(s) & space &= -S(s)D(s) & &= - (-F(s)N(s) ) \ &&&& &=F(s) N(s) $ === Analisi in frequenza della funzione di sensitività complementare <analisi_funzione_sensitivita_complementare> $ F(s) = frac(L(s),1+L(s)) $ passiamo alle frequenze $ |F(j omega)| &= lr(| frac(L(j omega),1+L(j omega)) |) \ &= frac(|L(j omega)|,|1+L(j omega)|) \ ==>_("scelta di" \ "design su " R(j omega)) & approx cases( 1 & omega << omega_c \ |L(j omega)| wide& omega >> omega_c ) $ Consideriamo $ omega_c$ pulsazione di taglio $ |F(j omega)|_("dB") approx cases( 0 "dB" & omega <= omega_c \ |L(j omega)|_("dB") wide& omega > omega_c ) $ #cfigure("Images/Analisi_sens_compl.png", 65%) === Analisi in frequenza della funzione di sensitività <analisi_funzione_sensitivita> $ S(s) &= frac(1,1+L(s)) space space & |S(j omega)| &= frac(1,|1+L(j omega)|) \ && & approx cases( dfrac(1,|L(j omega)|) wide& omega <= omega_c \ \ 1 & omega > omega_c ) space& $ #v(2em) $ |S(j omega)|_( "dB") approx cases( - |L(j omega)|_( "dB") wide& omega <= omega_c \ 0 "dB" & omega > omega_c ) $ #cfigure("Images/Analisi_sens.png", 60%) === Analisi in frequenza della funzione di sensitività del controllo <analisi_funzione_sensitivita_controllo> $ Q(s) &= frac(R(s),1+R(s) G(s)) space space& |Q(j omega)| &= lr(| frac(R(s),1+R(s) G(s)) |) \ && & approx cases( dfrac(1,G(j omega)) wide& omega <= omega_c \ \ R(j omega) & omega > omega_c ) $ #v(2em) $ |Q(j omega)|_("dB") approx cases( -|G(j omega)|_("dB") wide& omega <= omega_c \ \ |R(j omega)|_( "dB") & omega > omega_c ) $ #cfigure("Images/Analisi_sens_controllo.png", 60%) A basse frequenze il modulo di $Q(j omega)$ dipende da $G(j omega)$, quindi non possiamo influenzarlo con il regolatore. Occorre evitare valori di $ omega_c$ troppo elevati. === Poli complessi coniugati di $bold(F(s))$ (sensitività complementare) <poli_complessi_coniugati_sens_complementare> La funzione di sensitività complementare può avere una coppia di poli c.c. dominanti $ L(s) = frac(20,(1+10s)(1+2s)(1+0.2s)) $ #cfigure("Images/Poli_cc_F(s).png", 65%) Mettiamo in relazione il picco di risonanza di $F (j omega)$ con lo smorzamento $ xi$ associato, assumendo che $ omega_n approx omega_C$. $ |F(j omega)| approx cases( 0 "dB" & omega <= omega_c \ |L(j omega)|_("dB") wide& omega > omega_c ) $ Approssimazione di $F(s)$ a poli complessi coniugati dominanti: #cfigure("Images/Poli_sensitivita_complementare.png", 65%) Assumendo $omega_n approx omega_c$, la funzione di sensitività complementare vale (si veda la @poli_complessi_coniugati_parte_reale_negativa[]) $ |F(j omega_(c))| &approx 1/(2 xi) $ dove $xi$ è lo smorzamento dei poli complessi coniugati. Altrimenti, tenendo conto che il modulo di $|L(j omega)|$ alla frequenza di taglio $omega_c$, come si vede dal grafico, vale $0$ dB (quindi 1) $ |F(j omega_c)| &= frac(overbrace(|L(j omega_c)|, 1), |1 + L(j omega_c)|) \ &= frac(1, |1 + underbrace(L(j omega_c), #text(10pt)[$1 dot e^(j phi_c)$])|) \ &= frac(1, |1+ cos phi_c + j sin phi_c|) \ &= frac(1,sqrt((1+ cos phi_c)^2 + (sin phi_c)^2)) \ &= frac(1, sqrt(1+ cos^2 phi_c + sin^2 phi_c + 2 cos phi_c )) \ &= frac(1, sqrt(2(1+cos phi_c))) $ dalla trigonometria sappiamo che $cos(phi_c) = - cos(pi + phi_c)$ e, ricordando la definizione di @eqt:margine_fase[margine di fase] $ frac(1, sqrt(2(1+cos(phi_c)))) &= frac(1, sqrt(2(1-cos M_(f)^("rad")) ) ) \ #text(fill: green, baseline: -1pt, size: 9pt)[$1 - cos alpha = 2 sin^2 frac(alpha,2) ==>$] &= frac(1, sqrt(4 sin^2dfrac(M_(f)^("rad"), 2) ) ) \ &= frac(1,2 sin dfrac(M_(f)^("rad"), 2)) $ Uguagliando le due espressioni si ha $ xi = sin frac(M_(f)^("rad"), 2) approx frac(M_(f)^("rad"), 2) $ si è potuto approssimare il seno perché la pulsazione di taglio è molto bassa. Convertendo i radianti in gradi $ xi &= frac(M_f, 2) frac(pi, 180) \ &= M_f dot frac( pi, 360) \ &= M_f dot frac(3.14, 3.6 times 100) \ & approx frac(M_f, 100) $ questa equazione mette in relazione la $F(j omega)$ e la $L(j omega)$. == Analisi statica: errore a un gradino Sia $e_infinity = display(lim_(t -> infinity)) e(t)$ con $e(t) = w(t) - y(t)$ errore in risposta a un gradino $w(t) = W 1(t)$. Utilizzando il @teorema_valore_finale[teorema del valore finale] $ e_(infinity) &= lim_(s -> 0) s E(s) \ #text(fill: green, size: 9pt)[$E_w (s) = S(s) W(s) ==>$] &= lim_(s -> 0) s S(s)W(s)\ #text(fill: green, size: 9pt)[$cal(L)[W 1(t)] = W/s ==>$] &= lim_(s -> 0) s S(s)W/s\ &= W lim_(s -> 0)S(s) $ Sia $L(s) = dfrac(N_L (s), D_L (s)) = dfrac(N_L (s), s^g D'_L (s))$ con $N_L (0) = mu$ e $D'_L (0) = 1$, allora $ lim_(s -> 0)S(s) &= lim_(s->0) frac(D_L (s), N_L (s) + D_L (s)) \ &= lim_(s->0) frac(s^g D'_L (s), N_L (s) + s^g D'_L (s)) \ &= frac(s^g, mu + s^g) $ Si ha quindi $ e_infinity = W lim_(s->0) frac(s^g, mu + s^g) = cases( dfrac(W, 1+mu) wide& g=0 \ 0 &g>0 ) $ == Analisi statica: errore a ingressi $frac(W, s^k)$ Sia $e_infinity = display(lim_(t -> infinity)) e(t)$ con $e(t) = w(t) - y(t)$ errore in risposta a un ingresso con trasformata $W(s) = dfrac(W, s^k)$ $ e_infinity &= lim_(s -> 0) s S(s) frac(W, s^k) \ &= W lim_(s->0) frac(s^(g-k+1), mu + s^g) = cases( infinity wide& g<k -1 \ dfrac(W,mu) &g=k-1 \ 0 & g>k-1 ) $ Quindi - se $g< k-1$ l'errore diverge - se $g=k-1$ l'errore a regime è finito e diminuisce all'aumentare di $mu$ - se $g>k-1$ l'errore a regime è nullo *Nota:* le precedenti valutazioni sono valide solo se il sistema in anello chiuso è asintoticamente stabile. Affinché l'errore a regime a $W(s) = dfrac(W, s^k)$ sia nullo occorre che $L(s)$ abbia un numero di poli almeno pari a $k$ (principio del modello interno). == Principio del modello interno Possiamo generalizzare il risultato precedente come segue. Affinché un segnale di riferimento (rispetto un disturbo di misura) con una componente spettrale alla frequenza $omega_0$ sia inseguito a regime perfettamente in uscita è necessario e sufficiente che - il sistema chiuso in retroazione sia asintoticamente stabile; - il guadagno d'anello $L(s)$ abbia una coppia di poli c.c. sull'asse immaginario con pulsazione naturale pari a $omega_0$. = Sistemi di controllo: progetto del regolatore Consideriamo il seguente schema di controllo in retroazione: #cfigure("Images/Regolatore_1.png", 67%) === Riepilogo specifiche *Stabilità robusta rispetto a incertezze*\ Stabilità in presenza di errori di modello o incertezze di parametri. *Precisione statica*\ Sia $e_infinity = display(lim_(t -> infinity)) e(t)$ il valore a regime dell'errore in risposta a riferimenti $w(t)$ o disturbi in uscita $d(t)$ "canonici"; la specifica da seguire è $ |e_(infinity)| <= e^star &space "oppure" & space e_infinity = 0 $ *Precisione dinamica*\ Tipicamente specifiche in termini di sovraelongazione e tempo di assestamento massimi; le specifiche da seguire sono $ S% <= S^star &space T_(a, epsilon) <= T^star $ *Attenuazione disturbo in uscita*\ Il disturbo in uscita $d(t)$, con una banda limitata in un range di pulsazioni $[w_(d,min), w_(d,max)]$, deve essere attenuato di $A_d$ dB ($A_d > 0$).2 *Attenuazione disturbo di misura*\ Il disturbo di misura $n(t)$, con una banda limitata in un range di pulsazioni $[w_(n,min), w_(n,max)]$, deve essere attenuato di $A_n$ dB ($A_n > 0$). *Nota:* in applicazioni ingegneristiche in genere $w_(d,max) << omega_(n,min)$ *Moderazione variabile di controllo $u(t)$*\ Contenimento dell'ampiezza della variabile di controllo $u$ in ingresso al sistema fisico (impianto). *Fisica realizzabilità del regolatore $R(s)$*\ Il regolatore deve essere un sistema proprio, quindi il grado relativo (differenza tra poli e zeri) deve essere maggiore o uguale a zero. == Specifiche in termini di guadagno d'anello === Stabilità robusta rispetto a incertezze Stabilità in presenza di errori di modello o incertezze di parametri; ad esempio massimo ritardo temporale $tau_("max")$ o massima incertezza sul guadagno statico $Delta mu_"max"$. === Specifica su $L(j omega)$ $ M_f >= M_f^star $ === Precisione statica Per soddisfare tali specifiche va considerata l'analisi statica effettuata sulla funzione di sensitività $S(s)$.\ Ad esempio: $|e_infinity| <= e^star$ in risposta a un gradino $w(t) = W 1(t), thick d(t) = D 1(t)$ con $|W|<= W^star$ e $|D|<= D^star$. $ e_infinity &= frac(W,1+mu) + frac(D,1+mu)\ &=frac(D+W,1+mu)\ &approx frac(D+W,mu) $ $ mu = L(0) >= frac(D^star+W^star,e^star) $ #v(5pt) Altro esempio: $e_(infinity) = 0$ in risposta a $W(s) = dfrac(W,s^k)$ e/o $D(s) = dfrac(D,s^k)$ #v(3pt) #align(center)[$L(s)$ deve avere $k$ poli nell'origine] #v(5pt) Se $|e_infinity| <= e^star$ in riposta a $W(s) = dfrac(W,s^k)$ e $D(s) = dfrac(D,s^k)$ allora #v(3pt) #align(center)[$k-1$ poli in $L(s)$ e $mu >= dfrac(D^star+W^star, e^star)$] #v(3pt) Se $e_infinity = 0$ in risposta a un disturbo sull'attuatore $D_a (s) = dfrac(D_a,s^k)$, allora $ D(s) = D_a (s) G(s) &space space E(s) = S(s)G(s)D_a (s) $ quindi #align(center)[$k$ poli nell'origine in $R(s)$] === Precisione dinamica Specifiche: $S% <= S^star$ e $T_(a,epsilon) <= T^star$. Se progettiamo $L(j omega)$ in modo che $F(j omega)$ abbia una coppia di poli complessi coniugati dominanti in $omega_n approx omega_c$ con coefficiente di smorzamento $xi$ allora, come abbiamo visto nella @poli_complessi_coniugati_sens_complementare[] $ xi approx frac(M_f,100) $ Perché $S% <= S^star$ allora $xi >=xi^star$, con $S^star = e^(frac(-pi xi^star,sqrt(1-(xi^star)^2)))$, e quindi $ M_f >= 100 xi^star $ Perché $T_(a,1) <= T^star$ allora, ricordando la @eqt:tempo_assestamento[], e sapendo che $T = dfrac(1, xi omega_n)$, $xi omega_n >= dfrac(4.6, T^star)$ $ M_f omega_c >= frac(460, T^star) $ #cfigure("Images/Specifiche_dinamiche.png", 70%) La zona proibita per il diagramma di fase va evitata *solo a $omega_c$*. === Attenuazione disturbo in uscita $d(t)$ Il disturbo in uscita $d(t)$, con una banda limitata in un range di pulsazioni $[omega_(d,min) , omega_(d,max)]$, deve essere attenuato di $A_d$ dB. (Nota: $A_d$ > 0). Ricordiamo che se $d(t) = D cos(omega t + phi)$ allora $ y(t) = |S(j omega)|D cos(omega t + phi + arg(S(j omega))) $ e che, grazie all' @analisi_funzione_sensitivita[analisi in frequenza della funzione di sensitività] $ |S(j omega)|_"dB" approx cases( -|L(j omega)|_"dB" &wide omega <= omega_c\ 0 &wide omega > omega_c ) $ Da specifica vogliamo $|S(j omega)|_"dB" ≤ -A_d "dB"$. Poiché $omega_(d,max) ≪ omega_c$ si ha $ |L(j omega)|_"dB" >= A_d "dB" $ Ad esempio, se $d(t)$ deve essere attenuato di 20 dB allora $|L(j omega)|_"dB">= 20 "dB"$. #cfigure("Images/Attenuazione_disturbo_uscita.png", 54%) === Attenuazione disturbo di misura $n(t)$ Il disturbo di misura $n(t)$, con una banda limitata in un range di pulsazioni $[omega_n,min , omega_n,max]$, deve essere attenuato di $A_n$ dB. Ricordiamo che se $n(t) = N cos(omega t + phi)$ allora $ y(t) = |F (j omega)|N cos(omega t + φ - arg(F (j omega))) $ e che, grazie all' @analisi_funzione_sensitivita_complementare[analisi in frequenza della funzione di sensitività complementare] $ |F (j omega)|_"dB" approx cases( 0 &wide omega <= omega_c\ |L(j omega)|_"dB" &wide omega > omega_c ) $ Da specifica vogliamo $|F (j omega)|_"dB" <= -A_n "dB"$. Poiché $omega_(n,min)>> omega_c$, si ha $ |L(j omega)|_"dB" <= -A_n "dB" $ Ad esempio se $n(t)$ deve essere attenuato di 20 dB allora $|L(j omega)|_"dB" <= -20 "dB"$. #cfigure("Images/Attenuazione_disturbo_misura.png", 50%) === Moderazione variabile di controllo $u(t)$ Contenimento dell'ampiezza della variabile di controllo $u$ in ingresso al sistema fisico (impianto). Ricordiamo che se $w(t) = W cos(omega t + phi)$ allora $ u(t) = |Q(j omega)|W cos(omega t + phi + arg(Q(j omega))) $ e che, grazie all' @analisi_funzione_sensitivita_controllo[analisi in frequenza della funzione di sensitività del controllo] $ |Q(j omega)|_"dB" approx cases( -|G(j omega)|_"dB" &wide omega <= omega_c\ |R(j omega)_"dB" &wide omega > omega_c ) $ Poiché vogliamo contenere $|Q(j omega)|_"dB"$ e non abbiamo controllo su $G(j omega)$ dobbiamo - limitare $omega_c$; - realizzare $R(j omega)$ passa-basso. #cfigure("Images/Moderazione_u.png", 70%) /*-------------RIVEDI-----------------*/ Il limite superiore su $omega_c$ può essere determinato dalle specifiche sulla variabile di controllo $u(t)$. === Fisica realizzabilità del regolatore Il regolatore deve essere un sistema proprio, quindi il grado relativo (differenza poli-zeri) deve essere maggiore o uguale a zero. A pulsazioni elevate la pendenza $-k_L$ dB/dec di $|L(j omega)|_"dB"$ è determinata dalla differenza tra poli (ciascuno contribuisce con pendenza -20dB/dec) e zeri (ciascuno contribuisce con pendenza 20dB/dec). Se a pulsazioni elevate $|G(j omega)|_"dB"$ ha pendenza $-k_G$ dB/dec allora $ -k_L <= -k_G $ perché sappiamo che $L(s) = R(s) G(s)$ e che i poli (che fanno diminuire la pendenza) di $R(s)$ sono maggiori o uguali agli zeri, quindi moltiplicando $R(s)$ con $G(s)$ otteniamo una funzione di trasferimento con una pendenza uguale o minore di quella di $G(s)$. === Riepilogo specifiche #cfigure("Images/Riepilogo_specifiche.png", 80%) == Sintesi del regolatore === Loop Shaping Il _loop shaping_, o sintesi per tentativi, consiste nel "dare forma" alla $L(j omega)$ in modo che: - il diagramma delle ampiezze non attraversi le regioni proibite in bassa e alta frequenza; - per $omega = omega_c$ rispetti il vincolo sul margine di fase. procedendo per tentativi basati su opportune considerazioni. == Struttura del regolatore È conveniente dividere il progetto in due fasi fattorizzando $R(s)$ come $ R(s) = R_s (s) R_d (s) $ cioè come prodotto di due regolatori, uno statico e uno dinamico. *Regolatore statico:* $ R_s (s) = mu_s/s^k $ progettato per soddisfare precisione statica e attenuazione dei disturbi $d(t)$. *Regolatore dinamico:* $ R_d (s) = mu_d frac(product_i (1+tau_i s) product_i (1+2 frac(zeta_i, alpha_(n,i))s + frac(s^2,alpha^2_(n,i))), product_i (1+T_i s) product_i (1+2 frac(xi_i, omega_(n,i))s + frac(s^2,omega^2_(n,i)))) $ progettato per soddisfare stabilità robusta, precisione dinamica, attenuazione dei disturbi $n(t)$, moderazione dell'ingresso di controllo e fisica realizzabilità. *Nota:* $mu_d$ può essere scelto solo se $mu_s$ non è stato imposto. == Sintesi del regolatore statico /*-------------------------RIVEDI----------------------------*/ Il guadagno $mu_s$ e il numero di poli nell'origine in $R_s (s)$ dipende dalla specifica sull'errore a regime $e_infinity$ in risposta a segnali canonici. Ad esempio, se dobbiamo soddisfare la specifica $|e_infinity| <= e^star$ in risposta ai gradini $w$ e $d$, con $G(s)$ senza poli nell'origine: possiamo scegliere $ R(s) = mu_s >= mu^star $ oppure $ R(s) = mu_s / s $ nel secondo caso potremo poi scegliere $mu_d$ “liberamente” purché consenta di rispettare i vincoli sull'attenuazione di $d$. == Sintesi del regolatore dinamico === Obiettivi La progettazione di $R_d (s)$ mira a #list() + imporre $omega_c$ in un certo intervallo; + garantire un dato margine di fase $M_f$, cioè $arg(L(j omega_c)) >= -180 + M_f$; + garantire una certa attenuazione e pendenza di $L(j omega)$, e anche di $R(j omega)$ a pulsazioni elevate. Per la *terza specifica* è sufficiente introdurre poli del regolatore a pulsazioni elevate. Utilizzeremo la sintesi per tentativi individuando dei possibili scenari in base al diagramma di $ G_e (s) = R_s (s) G(s) $ che chiameremo *sistema esteso*. === Scenario A Nell'intervallo (“centrale”) di pulsazioni ammissibili per la pulsazione di attraversamento $omega_c$ esiste un sotto-intervallo in cui la fase di $G_e (j omega)$ rispetta il vincolo sul margine di fase. #cfigure("Images/Scenario_A.png", 60%) *Obiettivo:* - attenuare (selettivamente) il diagramma delle ampiezze (traslarlo in basso) in modo che $omega_c$ ricada nel sotto-intervallo in cui in vincolo sul margine di fase è rispettato; - alterare meno possibile la fase. *Azioni possibili:* - Se $mu_d$ libero, allora scegliere $R_d (s) = mu_d$ con $mu_d < 1$; - Se $mu_d$ bloccato (vincolato dalla scelta di $mu_s$), allora attenuare mediante inserimento di poli e zeri in $R_d (s)$. #pagebreak() ==== Caso $mu_d$ libero #nfigure("mu_d_libero.png", 85%) ==== Caso $mu_d$ vincolato Per attenuare solo nel range di pulsazioni selezionato progettiamo #tageq($R_d (s) = frac(1 + alpha tau s, 1+ tau s)$, $0<alpha<1$) cioè una rete ritardatrice #nfigure("mu_d_vincolato_1.png", 85%) #nfigure("mu_d_vincolato_2.png", 85%) #pagebreak() === Rete ritardatrice #nfigure("Rete_ritardatrice.png", 85%) ==== Tuning approssimato Il nostro obiettivo è calcolare $alpha$ e $tau$ in modo che $L(j omega)$ abbia una pulsazione di attraversamento $omega_c^star$ e valga $arg(L(j omega_c^star)) approx arg(G_e (j omega_c^star))$. Procediamo quindi a #list(tight: false, spacing: 12pt, [scegliere $alpha$ tale che $20 log alpha approx - |G_e (j omega_c^star)|_"dB"$;], [scegliere $tau$ tale che $dfrac(1,alpha tau) <= dfrac(omega_c^star, 10)$.] ) ==== Formule di inversione Dobbiamo calcolare $alpha$ e $tau$ in modo che alla pulsazione $omega_c^star$ (pulsazione a cui vorremmo $|L(j omega)|_"dB" = 0$) la rete ritardatrice abbia una attenuazione $o < M^star < 1$ e uno sfasamento $-frac(pi,2) < phi^star < 0$, ovvero $ R_d (j omega_c^star) = M^star e^(j phi^star) $ Poniamo $ &frac(1+j alpha tau omega_c^star, 1+j tau omega_c^star) = M^star (cos phi^star + j sin phi^star)\ ==>&1+j alpha tau omega_c^star = M^star (cos phi^star + j sin phi^star) (1+j tau omega_c^star) $ Uguagliano parte reale e parte immaginaria: $ 1 &= M^star cos phi^star - M^star tau omega_c^star sin phi^star\ alpha tau omega_c^star &= M^star tau omega_c^star cos phi^star + M^star sin phi^star $ Arriviamo così alle formule di inversione $ tau = frac(cos phi^star - dfrac(1,M^star), omega_c^star sin phi^star) space space alpha tau = frac(M^star - cos phi^star, omega_c^star sin phi^star) $ *Nota:* perché si abbia $alpha > 0$ occorre che $M^star < cos phi^star$. Quindi, noi vogliamo che $|L(j omega)|_"dB" = 0$ per $omega = omega_c^star$. Per farlo scegliamo una $omega_c^star$ e ricaviamo il $M_f^star$ dalle specifiche.\ Calcoliamo quindi $M^star$ e $phi^star$ imponendo $ |G_e (j omega_c^star)|_"dB" + 20 log M^star = 0 &space M_f^star = 180 degree + arg(G_e (j omega_c^star)) + phi^star $ verificando che i risultati trovati soddisfino le relazioni seguenti $ 0 < M^star < 1 space -frac(pi,2) < phi^star < 0 space M^star < cos phi^star $ e, infine, calcolare $alpha$ e $tau$ mediante formule di inversione. === Scenario B Nell'intervallo "centrale" di pulsazioni ammissibili per la pulsazione di attraversamento $omega_c$ *NON* esistono pulsazioni in cui la fase di $G_e (j omega)$ rispetta il vincolo sul margine di fase. #nfigure("Scenario_B.png", 70%) *Obiettivo:* - modificare il diagramma delle fasi (aumentare la fase) nell'intervallo in modo che il vincolo sul margine di fase sia rispettato; - amplificare meno possibile l'ampiezza. *Azioni possibili:* - aggiungere uno o più zeri (a pulsazioni precedenti quella di attraversamento desiderata) per aumentare la fase; - aggiungere uno o più poli a pulsazioni più alte per la fisica realizzabilità e per evitare una eccessiva amplificazione. Definizione di poli e zeri: @poli_e_zeri[]. ==== Aggiunta di uno zero #nfigure("Scenario_B_aggiunta_zero.png", 70%) #pagebreak() ==== Aggiunta di due zeri #nfigure("Scenario_B_aggiunta_2_zeri.png", 70%) ==== Progettazione Tenendo conto dell'aggiunta di uno o due poli si può progettare $R_d (s)$ come segue. Si realizza una rete anticipatrice #tageq($R_d (s) = frac(1 + tau s, 1 + alpha tau s)$, $0< alpha < 1$) O, nel caso sia necessario un anticipo di fase maggiore, si possono aggiungere due zeri #tageq($R_d (s) = frac(1 + tau_1 s, 1 + alpha_1 tau_1 s) frac(1 + tau_2 s, 1 + alpha_2 tau_2 s)$, $0< alpha_1 < 1, #h(5pt) 0< alpha_2 < 1$) Una volta realizzata una rete anticipatrice (singola o multipla) si possono verificare due casi: #enum(numbering: n => $bold(B_#n)$, [$omega_c$ è nell'intervallo di specifica e il vincolo sul margine di fase è rispettato. In questo caso il progetto è terminato;], [$omega_c$ è fuori dall'intervallo di specifica o in un intervallo in cui il vincolo sul margine di fase non è rispettato (ci siamo comunque ricondotti ad uno scenario A , quindi esiste un sotto-intervallo in cui il vincolo sul margine di fase è rispettato).] ) #heading(level: 5, numbering: none)[Caso *$B_2$*] - Se $mu_d$ libero allora scegliamo $mu_d < 1$ per attenuare $ R_d (s) = mu_d frac(1+ tau_b s, 1+ alpha_b tau_b s) $ - Se $mu_d$ bloccato $ R_d (s) = mu_d frac(1+ alpha_a tau_a s, 1+ tau_a s) frac(1+ tau_b s, 1+ alpha_b tau_b s) $ Quest'ultimo tipo di regolatore viene chiamato *rete ritardo-anticipo*. #nfigure("Rete_ritardo_anticipo.png", 66%) ==== Rete anticipatrice #nfigure("Scenario_B_Rete_anticipatrice.png", 88%) #heading(level: 5, numbering: none)[Formule di inversione] Calcoliamo $alpha$ e $tau$ in modo che alla pulsazione $omega_c^star$ (pulsazione a cui vorremmo $|L(j omega)|_"dB" = 0$) la rete anticipatrice abbia una amplificazione $M^star > 1$ e uno sfasamento $0 < phi^star < pi/2$ , ovvero $ R_d (j omega_c^star) = M^star e^(j phi^star) $ Poniamo $ frac(1+j tau omega_c^star, 1+j alpha tau omega_c^star) = M^star (cos phi^star + j sin phi^star) space 1 + j tau omega_c^star = M^* (cos phi^star + j sin phi^star)(1+j alpha tau omega_c^star) $ Uguagliando parte reale e parte immaginaria $ 1 &= M^star cos phi^star - M^star alpha tau omega_c^star sin phi^star\ tau omega_c^star &= M^star alpha tau omega_c^star cos phi^star + M^star sin phi^star $ Quindi arriviamo alle seguenti formule di inversione $ tau = frac(M^star - cos phi^star, omega_c^star sin phi ^star) space alpha tau = frac(cos phi^star - dfrac(1,M^star), omega_c^star sin phi ^star) $ *Nota:* perché si abbia $alpha > 0$ occorre che cos $phi^star > dfrac(1,M^star)$. Come sempre, vogliamo che $|L(j omega)|_"dB" = 0$ per $omega = omega_c^star$, quindi - scegliamo $omega_c^star$ e ricaviamo $M_f^star$ dalle specifiche - calcoliamo $M^star$ e $phi^star$ imponendo $ |G_e (j omega_c^star)|_"dB" + 20 log M^star = 0 space M_f^star = 180 degree + arg(G_e (j omega_c^star)) + phi^star $ - verifichiamo che $M^star > 1$, $0 < phi^star < pi , cos phi^star > dfrac(1,M^star)$ - calcoliamo $alpha$ e $tau$ mediante le formule di inversione. == Controllori PID I _controllori PID_, che sta per *controllori ad azione Proporzionale Integrale Derivativa*, sono tra i più usati in ambito industriale. Tra i motivi di questo c'è sicuramente il fatto di poter controllare in modo soddisfacente un'ampia gamma di processi; ma anche perché possono essere usati in casi un cui non vi sia un modello matematico preciso del sistema sotto controllo, perché sono state sviluppati negli anni delle regole per la loro taratura automatica.\ Essi, grazie alla loro semplicità, possono essere realizzati con varie tecnologie, come: meccanica, pneumatica, idraulica, elettronica analogica e digitale, e questo ovviamente implica una grande disponibilità commerciale. Un PID ideale è rappresentato dalla seguente espressione: $ R(s) = K_p (1 + dfrac(1,T_i s) + T_d s) $ ove $T_i$ è il _tempo integrale_ e $T_d$ il _tempo derivativo_. #nfigure("PID_1.png", 70%) L'ingresso di controllo è $ U(s) &= R(s) E(s) \ &= K_p E(s) + frac(K_p,T_i) frac(E(s),s) + K_p T_d s E(s) $ che nel dominio del tempo equivale a $ u(t) = cal(L)^(-1) [U(s)] = underbrace(K_p e(t), #text(size: 10pt)[termine \ Proporzionale]) + underbrace(frac(K_p, T_i)integral_0^t e(tau) thick d tau, #text(size: 10pt)[termine \ Integrale]) + underbrace(K_p T_d frac(d e(t), d t),#text(size: 10pt)[termine \ Derivativo]) $ *Attenzione: * il PID ideale non è fisicamente realizzabile. Infatti, sviluppando i calcoli, si vede che la funzione di trasferimento del controllore ha un numeratore con grado più elevato del denominatore: $ R(s) &= K_p (1 + dfrac(1,T_i s) + T_d s)\ &= frac(K_p T_i s + K_p + K_p T_i T_d s^2, T_i s) $ Il PID “reale” (fisicamente realizzabile) richiede di aggiungere un polo in alta frequenza: $ R^("fr") (s) = K_p (1 + dfrac(1,T_i s) + T_d s) frac(1, 1+T_p s) $ Raccogliendo i termini e definendo opportunamente $tau_1$ , $tau_2$ possiamo vedere che il PID reale è una combinazione di una rete anticipatrice e di una rete ritardatrice: $ R^("fr") (s) &= underbrace(frac(K_p, T_i), mu) frac(T_i s + 1 + T_i T_d s^2, s) frac(1, 1+T_p s)\ &= mu frac((1+tau_1 s)(1+ tau_2 s), s) frac(1, 1+T_p s) $ === Casi speciali *Regolatori P:* se $T_i -> infinity$ e $T_d = 0$, quindi il termine integrale e quello derivativo sono assenti, si ottiene un regolatore proporzionale $R(s) = K_p$. *Regolatori I:* in assenza di termine proporzionale e derivativo, si ottiene un regolatore puramente integrale $R(s) = frac(K_i, s)$. Si può interpretare come una rete ritardatrice con il polo sposto nell'origine e con lo zero all'infinito. #par(leading: 1.2em)[ *Regolatori PI:* se $T_d = 0$, quindi manca il termine derivativo, si ottiene un regolatore proporzionale integrale $R(s) = K_p (1 + dfrac(1, T_i s))$. Possono essere visti come reti ritardatrici con polo nell'origine e zero in $-dfrac(1, T_i)$. ] *Regolatori PD:* se $T_i -> infinity$, quindi manca il termine integrale, si ottiene un regolatore proporzionale derivativo $R(s) = K_p (1+T_d s)$. Possono essere visti come reti anticipatrici con zero in $-dfrac(1,T_d)$ e un polo posto all'infinito (nel caso ideale).
https://github.com/Jollywatt/typst-fletcher
https://raw.githubusercontent.com/Jollywatt/typst-fletcher/master/tests/node-name/test.typ
typst
MIT License
#set page(width: auto, height: auto, margin: 1em) #import "/src/exports.typ" as fletcher: diagram, node, edge #diagram( node((0,0), [A], name: <a>), node((2,0), [B], name: "b"), edge(<a>, <b>, [by label], ">>-}>"), edge(<a>, "rrr", "--", snap-to: (<b>, auto)) )
https://github.com/DJmouton/Enseignement
https://raw.githubusercontent.com/DJmouton/Enseignement/main/SNT/Réseaux sociaux/Activité confidentialité.typ
typst
#import "/Templates/layouts.typ": SNT, titre, sous_titre #import "/Templates/utils.typ": cadre, pointillets #show: doc => SNT(doc) #sous_titre[SNT - Réseaux Sociaux - Activité 2] #titre[confidentialité et fuites #linebreak() de données personnelles] Volontairement ou non, tout internaute divulgue de nombreuses informations personnelles. Il s'agit donc d'adopter de bons réflexes et de paramétrer convenablement ses abonnements. #cadre(titre: "L'essentiel")[ L'agence de protection des consommateurs américaine a infligé en juillet 2019 une amende record de cinq milliards de dollars à Facebook pour avoir "trompé" ses utilisateurs sur le contrôle de leur vie privée, notamment lors d'une fuite massive de données personnelles vers la firme britannique Cambridge Analytica. Cette fuite s'est praduite entre 2014 et 2018, et près de 87 millions d'utilisateurs ont été concernés. Les données aspirées par Cambridge Analytica ont notamment été exploitées pendant la campagne présidentielle de <NAME> en 2016. Elles ont également servi à orchestrer la communication d'un mouvement favorable au "leave" avant le référendum sur l'appartenance du Royaume-Uni à l'Union européenne en juin 2016. ] === 1. Tout individu abonné à un réseau social et actif sur ce dernier possède une identité numérique. À votre avis, quelles informations vous concernant sont accessibles par le biais des réseau sociaux que vous utilisez. #pointillets #pointillets #pointillets === 2. Est-il possible de disposer d'une fausse identité numérique ? Si oui, comment ? Expliquer pourquoi il faut être vigilant lorsqu'on entre en contact avec une personne sur un réseau social. #pointillets #pointillets #pointillets === 3. On donne ci-contre un extrait du menu "Confidentialité" sur Facebook. Expliquer pourquoi il est important de régler correctement ces paramètres. #pointillets #pointillets #pointillets === 4. Expliquer en quoi la fuite de données personnelles via le réseau Facebook a pu permettre d'influencer des électeurs lors de l'élection présidentielle américaine de 2016, et lors du vote sur l'appartenance du Royaume-Uni à l'Union européenne (communément appelé "Brexit"). #pointillets #pointillets #pointillets
https://github.com/onecalfman/TypstGenerator.jl
https://raw.githubusercontent.com/onecalfman/TypstGenerator.jl/main/README.md
markdown
MIT License
# TypstGenerator [![Build Status](https://github.com/onecalfman/TypstGenerator.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/onecalfman/TypstGenerator.jl/actions/workflows/CI.yml?query=branch%3Amain) This package can be used to generate [Typst](https://typst.app/home) through julia code. ## Basic usage The function naming follows the typst function names. ```julia using TypstGenerator t1 = text("some text") t2 = text("some text", size = 20pt) t3 = text("some text", size = 20pt, fill = :red) ``` A difference from typst however is, that the content always comes first. An arbitrary number of named arguments can be supplied. These will just be converted into typst syntax. This package currently doesn't check the validity of the supplied option in julia itself. Refer to the typst documentation eg. [text](https://typst.app/docs/reference/text/text/) for valid options. The elements are then rendered to String using the typst function. ```julia typst([t1,t2,t3]) ``` ![](./docs/src/assets/example_1.png) ### Listlike Elements like grid, table or page accept lists of typst arguments. ```julia block( grid(map(x -> text("field $(x)"), 1:3), columns = [fr(1), fr(2), fr(5)], row_gutter = 3mm, ), line(length = 0.5), grid(map(x -> text("field $(x)"), 4:12), columns = [fr(1), fr(2), fr(5)], row_gutter = 3mm, ) ) ``` ![](docs/src/assets/example_2.png) Column or row width can be specified using the fr function, following the css flex logic. Multiple columns with the same fraction can also be constructed with fr(1,n). Note that arguments, that are written with a - in typst are written with _ in julia. Floats are interpretted as percent when given as an named argument. ### set ```julia block( set(text, size = 10pt), "10pt text", "10pt text", set(text, size = 15pt, fill = cmyk(0.9,0.2,0.4,0.2)), "50pt text", literal("#overline[literal]"), set(text, size = 10pt), "colored text", ) ``` ![](docs/src/assets/example_3.png) Set syntax works pretty similar to typst itself. For arbitrary typst commands use the literal function. Strings in typst functions will be interpreted as text. ### figures ```julia page( figure( grid(map(x -> square( align( scale( math(" A = pi r^2 "), x = x/20, y = x/20), :bottom), size = x * mm), 5:5:30), columns = fr.(1:length(5:5:30)), ), label = :label1, caption = text("a figure") ), lorem(20), lorem(20), ref(:label1) ) ``` Figures can be referenced, using the label option with some symbol. ![](docs/src/assets/example_4.png) ### Example Check the example folder for a more complex and comprehensive example. For a full list of functions check the TypstGenerator.jl file. ## Things that don't yet work. - Text styles besides text. As of today only text is implemented. Empy, overline etc are not yet supported. - References when a figure is in an align. - repeat - measure - counter - layout - locate - query - selector - state - style
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/unichar/0.1.0/ucd/block-16A0.typ
typst
Apache License 2.0
#let data = ( ("RUNIC LETTER FEHU FEOH FE F", "Lo", 0), ("RUNIC LETTER V", "Lo", 0), ("RUNIC LETTER URUZ UR U", "Lo", 0), ("RUNIC LETTER YR", "Lo", 0), ("RUNIC LETTER Y", "Lo", 0), ("RUNIC LETTER W", "Lo", 0), ("RUNIC LETTER THURISAZ THURS THORN", "Lo", 0), ("RUNIC LETTER ETH", "Lo", 0), ("RUNIC LETTER ANSUZ A", "Lo", 0), ("RUNIC LETTER OS O", "Lo", 0), ("RUNIC LETTER AC A", "Lo", 0), ("RUNIC LETTER AESC", "Lo", 0), ("RUNIC LETTER LONG-BRANCH-OSS O", "Lo", 0), ("RUNIC LETTER SHORT-TWIG-OSS O", "Lo", 0), ("RUNIC LETTER O", "Lo", 0), ("RUNIC LETTER OE", "Lo", 0), ("RUNIC LETTER ON", "Lo", 0), ("RUNIC LETTER RAIDO RAD REID R", "Lo", 0), ("RUNIC LETTER KAUNA", "Lo", 0), ("RUNIC LETTER CEN", "Lo", 0), ("RUNIC LETTER KAUN K", "Lo", 0), ("RUNIC LETTER G", "Lo", 0), ("RUNIC LETTER ENG", "Lo", 0), ("RUNIC LETTER GEBO GYFU G", "Lo", 0), ("RUNIC LETTER GAR", "Lo", 0), ("RUNIC LETTER WUNJO WYNN W", "Lo", 0), ("RUNIC LETTER HAGLAZ H", "Lo", 0), ("RUNIC LETTER HAEGL H", "Lo", 0), ("RUNIC LETTER LONG-BRANCH-HAGALL H", "Lo", 0), ("RUNIC LETTER SHORT-TWIG-HAGALL H", "Lo", 0), ("RUNIC LETTER NAUDIZ NYD NAUD N", "Lo", 0), ("RUNIC LETTER SHORT-TWIG-NAUD N", "Lo", 0), ("RUNIC LETTER DOTTED-N", "Lo", 0), ("RUNIC LETTER ISAZ IS ISS I", "Lo", 0), ("RUNIC LETTER E", "Lo", 0), ("RUNIC LETTER JERAN J", "Lo", 0), ("RUNIC LETTER GER", "Lo", 0), ("RUNIC LETTER LONG-BRANCH-AR AE", "Lo", 0), ("RUNIC LETTER SHORT-TWIG-AR A", "Lo", 0), ("RUNIC LETTER IWAZ EOH", "Lo", 0), ("RUNIC LETTER PERTHO PEORTH P", "Lo", 0), ("RUNIC LETTER ALGIZ EOLHX", "Lo", 0), ("RUNIC LETTER SOWILO S", "Lo", 0), ("RUNIC LETTER SIGEL LONG-BRANCH-SOL S", "Lo", 0), ("RUNIC LETTER SHORT-TWIG-SOL S", "Lo", 0), ("RUNIC LETTER C", "Lo", 0), ("RUNIC LETTER Z", "Lo", 0), ("RUNIC LETTER TIWAZ TIR TYR T", "Lo", 0), ("RUNIC LETTER SHORT-TWIG-TYR T", "Lo", 0), ("RUNIC LETTER D", "Lo", 0), ("RUNIC LETTER BERKANAN BEORC BJARKAN B", "Lo", 0), ("RUNIC LETTER SHORT-TWIG-BJARKAN B", "Lo", 0), ("RUNIC LETTER DOTTED-P", "Lo", 0), ("RUNIC LETTER OPEN-P", "Lo", 0), ("RUNIC LETTER EHWAZ EH E", "Lo", 0), ("RUNIC LETTER MANNAZ MAN M", "Lo", 0), ("RUNIC LETTER LONG-BRANCH-MADR M", "Lo", 0), ("RUNIC LETTER SHORT-TWIG-MADR M", "Lo", 0), ("RUNIC LETTER LAUKAZ LAGU LOGR L", "Lo", 0), ("RUNIC LETTER DOTTED-L", "Lo", 0), ("RUNIC LETTER INGWAZ", "Lo", 0), ("RUNIC LETTER ING", "Lo", 0), ("RUNIC LETTER DAGAZ DAEG D", "Lo", 0), ("RUNIC LETTER OTHALAN ETHEL O", "Lo", 0), ("RUNIC LETTER EAR", "Lo", 0), ("RUNIC LETTER IOR", "Lo", 0), ("RUNIC LETTER CWEORTH", "Lo", 0), ("RUNIC LETTER CALC", "Lo", 0), ("RUNIC LETTER CEALC", "Lo", 0), ("RUNIC LETTER STAN", "Lo", 0), ("RUNIC LETTER LONG-BRANCH-YR", "Lo", 0), ("RUNIC LETTER SHORT-TWIG-YR", "Lo", 0), ("RUNIC LETTER ICELANDIC-YR", "Lo", 0), ("RUNIC LETTER Q", "Lo", 0), ("RUNIC LETTER X", "Lo", 0), ("RUNIC SINGLE PUNCTUATION", "Po", 0), ("RUNIC MULTIPLE PUNCTUATION", "Po", 0), ("RUNIC CROSS PUNCTUATION", "Po", 0), ("RUNIC ARLAUG SYMBOL", "Nl", 0), ("RUNIC TVIMADUR SYMBOL", "Nl", 0), ("RUNIC BELGTHOR SYMBOL", "Nl", 0), ("RUNIC LETTER K", "Lo", 0), ("RUNIC LETTER SH", "Lo", 0), ("RUNIC LETTER OO", "Lo", 0), ("RUNIC LETTER FRANKS CASKET OS", "Lo", 0), ("RUNIC LETTER FRANKS CASKET IS", "Lo", 0), ("RUNIC LETTER FRANKS CASKET EH", "Lo", 0), ("RUNIC LETTER FRANKS CASKET AC", "Lo", 0), ("RUNIC LETTER FRANKS CASKET AESC", "Lo", 0), )
https://github.com/Fabioni/Typst-TUM-Thesis-Template
https://raw.githubusercontent.com/Fabioni/Typst-TUM-Thesis-Template/main/template/Chapter_Appendix.typ
typst
MIT No Attribution
#import "utils.typ": todo #heading(numbering: none)[Appendix A: Supplementary Material] -- Supplementary Material -- #todo[Write here the appendix]
https://github.com/CedricMeu/ugent-typst-template
https://raw.githubusercontent.com/CedricMeu/ugent-typst-template/main/0.1.0/lib/research-questions.typ
typst
#let rqs_state = state("rqs", none) #let init-rqs(rqs) = { rqs_state.update(rqs) } #let outline-rqs() = { set enum(numbering: (..nums) => "RQ" + nums.pos().map(str).join(".") + ":", full: true) rqs_state.display(rqs => { for key in rqs.keys() { [+ #rqs.at(key)] } }) } #let ref-rq(key) = { rqs_state.display(rqs => { let pos = rqs.keys().position(v => v == key) + 1 [RQ#pos] }) } #let cite-rq(key) = { rqs_state.display(rqs => { rqs.at(key) }) }
https://github.com/herlev/inktyp
https://raw.githubusercontent.com/herlev/inktyp/master/readme.md
markdown
# inktyp Insert and edit [typst](https://typst.app/) equations in inkscape. ![](img/demo.gif) ## Installation ```bash mkdir -p ~/.config/inkscape/extensions cd ~/.config/inkscape/extensions git clone https://github.com/herlev/inktyp cd inktyp cargo install --path . ``` ### Set a keyboard shortcut In Inkscape go to `Edit > Preferences > Interface > Keyboard` and set a shortcut for inktyp under `Extensions`. ![](img/inkscape-preferences.png)
https://github.com/isometricneko/typst-example
https://raw.githubusercontent.com/isometricneko/typst-example/main/chap1.typ
typst
#import "preamble.typ": * = Chapter 1 #cite(<cardoso2023mcgdiff>) <here_is_chap1> #locate(loc => bib_state.at(query(<here_is_chap1>, loc).first().location()))
https://github.com/Toniolo-Marco/git-for-dummies
https://raw.githubusercontent.com/Toniolo-Marco/git-for-dummies/main/slides/practice/merge.typ
typst
#import "@preview/touying:0.5.2": * #import themes.university: * #import "@preview/numbly:0.1.0": numbly #import "@preview/fletcher:0.5.1" as fletcher: node, edge #let fletcher-diagram = touying-reducer.with(reduce: fletcher.diagram, cover: fletcher.hide) #import "../components/gh-button.typ": gh_button #import "../components/git-graph.typ": branch_indicator, commit_node, connect_nodes, branch #import "../components/utils.typ": rainbow #import "../components/thmbox.typ": custom-box, alert-box #grid(columns:2, column-gutter:5%, image("/slides/img/meme/merge-conflicts.png", width:90%), [To *combine functionality implemented in 2 different branches*, there are several techniques; in this section we will only cover the classic _merge method_, as it is the most _safe_ and _simple_. In the chapter theory, we saw the workflow we want to achieve. ] ) --- There are several situations we can find ourselves in: if the branch we want to merge has not changed during the development of our feature, the merge will be called _fast-forward_. #footnote([It is assumed that the branch _main_ label is always on the last commit _blue_.]) #v(10%) #align(center)[ #scale(100%)[ #set text(11pt) #fletcher-diagram( node-stroke: .1em, node-fill: none, spacing: 4em, mark-scale: 50%, branch( // main branch name:"main", color:blue, start:(0,1), length:3, ), connect_nodes((3,1),(4,2),orange), branch( // feature branch name:"feature", color:orange, start:(3,2), length:3, head: 2, ), ) ] ] --- In such situations we are sure that *no merge conflicts will arise*, and this can be done with the commands: `git switch main`, followed by `git merge feature`. By doing so we will get a tree similar to this one: #v(10%) #align(center)[ #scale(100%)[ #set text(11pt) #fletcher-diagram( node-stroke: .1em, node-fill: none, spacing: 4em, mark-scale: 50%, branch( // main branch name:"main", color:blue, start:(0,1), length:6, head: 5 ), branch_indicator("feature", (0,1.5), blue) ) ] ] --- What if instead there were commits on the main during the development of the feature we are interested in? (Someone implemented _feature 1_) #v(10%) #align(center)[ #scale(100%)[ #set text(11pt) #fletcher-diagram( node-stroke: .1em, node-fill: none, spacing: 4em, mark-scale: 50%, branch( // main branch name:"main", color:blue, start:(0,1), length:3, ), connect_nodes((3,1),(4,1), blue, bend:20deg), branch( // feature 1 branch name:"feature 1", indicator-xy: (3.5,1.5), color:blue, start:(3,1), length:3, ), connect_nodes((3,1),(4,2),teal), branch( // feature 2 branch name:"feature 2", color: teal, start: (3,2), length: 3, head: 2 ) ) ] ] #v(10%) The graph would look like this: the _main_ branch has undergone changes and to highlight that the _feature 1_ has been integrated into the _main_ we used the same blue color but with different node linkage to highlight the start of commits belonging to the _feature 1_. --- We can *redraw the graph* in the following way, where the *branch labels are aligned with the commit they are on*: #footnote([This representation is similar to that of the VS-Code Git Graph plug-in that we recommend.]) #align(center)[ #scale(100%)[ #set text(11pt) #fletcher-diagram( node-stroke: .1em, node-fill: none, spacing: 4em, mark-scale: 50%, branch( // main branch name:"main", indicator-xy: (5.75,0), color:blue, start:(0,1), length:3, ), connect_nodes((3,1),(4,1), blue, bend:0deg), branch( // feature 1 branch name:"feature 1", indicator-xy: (5.75,0.5), color:blue, start:(3,1), length:3, ), connect_nodes((3,1),(4,2),teal), branch( // feature 2 branch name:"feature 2", indicator-xy: (5.75,2.5), color: teal, start: (3,2), length: 3, head: 2 ) ) ] ] #pause In this case we cannot know a priori whether there will be merge conflicts or not. --- To merge the two branches, as before, we can use the commands: `git switch main`, followed by `git merge feature-2`. If there are merge conflicts, we will be notified on the terminal and will have to resolve them manually. As an example, I used a different string on the same line of the README.md file in two different branches. The result when trying to merge the second branch is as follows: ```bash ➜ git merge feature-2 Auto-merging README.md CONFLICT (content): Merge conflict in README.md Automatic merge failed; fix conflicts and then commit the result. ``` --- Depending on the editor we use, files containing conflicts will or will not be highlighted. However each file with conflict on opening will show something similar: #align(center)[ #image("/slides/img/file-with-merge-conflicts.png") ] --- - At this point all we have to do is remove the change we do not want to keep or alternatively combine both. - We continue by saving the file, closing it, and making sure it is in the staging area with the command: `git add ...`. - Now we can run the `git commit` command (which will assign the default message: _“Merge branch feature-2”_). Our commit history will be: #align(center)[ #scale(100%)[ #set text(11pt) #fletcher-diagram( node-stroke: .1em, node-fill: none, spacing: 4em, mark-scale: 50%, branch( // main branch name:"main", indicator-xy: (6.75,0.5), color:blue, start:(0,1), length:7, head: 6, commits:("", "", "", "", "", "", "Merge branch feature-2"), angle: 0deg, alignment: bottom ), branch_indicator("feature 1", (5.75,0.5), blue), connect_nodes((3,1),(4,2),teal), branch( // feature 2 branch name:"feature 2", indicator-xy: (5.75,2.5), color: teal, start: (3,2), length: 3, ), //merge edge connect_nodes((6,2),(7,1),teal), ) ] ] --- #custom-box(title:"Note")[ The _feature-2_ branch has not been deleted and is still on its last commit. The _feature-1_ branch is also still on its last commit. For both _feature_ branches this is a “merge _fast-forward_”: in fact if we move to either one and give the command `git merge main` we will have no conflicts whatsoever. ] #align(center)[ #scale(90%)[ #set text(10pt) #fletcher-diagram( node-stroke: .1em, node-fill: none, spacing: 4em, mark-scale: 50%, branch( // main branch name:"main", indicator-xy: (6.75,0.55), color:blue, start:(0,1), length:7, head: 6, commits:("", "", "", "", "", "", "Merge branch feature-2"), angle:0deg, alignment: bottom ), branch_indicator("feature 1", (7,0.15), blue), branch_indicator("feature 2", (6.5,0.15), blue), //other branch stuff connect_nodes((3,1),(4,2),teal), branch( // old branch name:"", color: teal, start: (3,2), length: 3, ), connect_nodes((6,2),(7,1),teal), ) ] ]
https://github.com/polarkac/MTG-Stories
https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/032%20-%20Ixalan/004_The%20Shapers.typ
typst
#import "@local/mtgstory:0.2.0": conf #show: doc => conf( "The Shapers", set_name: "Ixalan", story_date: datetime(day: 27, month: 09, year: 2017), author: "<NAME>, <NAME> & <NAME>", doc ) = KOPALA We were here in the beginning. Before the first patter of unwebbed feet upon the dirt, my people swam the waters of Ixalan and listened. The Nine Tributaries taught us their secret names, and in return we promised to call upon them only in need. We whispered to the roots as we stepped among them, and they curled away to clear our path—not because we were their masters, but because we alone knew how to ask. We spoke to the wind and the waves and the tangled branches. We shaped them to suit our needs, and they shaped us to suit theirs. The beastmasters forget that we were here before them, though they once knew. The bloodsuckers and the brigands, perhaps, have never known—though they, too, have forgotten many things that only we remember. We are mighty, but we used to be so much more. #figure(image("004_The Shapers/01.jpg", width: 100%), caption: [Kopala, Warden of Waves | Art by Magali Villeneuve], supplement: none, numbering: none) I wonder, at times, what it was like before the beastmasters had their turn. We ruled these lands, and once controlled its fate. I wonder what sort of Shaper I would be had I lived in those days, had I known what they did. It is useless to speculate, of course. My present is all I can truly know. Tishana has done her best to teach me that. The "whys" and "what-ifs" cannot change the course of a river. There are nine of us Shapers who lead the nine great tribes. The Tributaries kindly share their names with us, each of us speaking for one of them, each of them guiding one of us. I was called something else, not so long ago, when I was but another shaman swimming these rivers. But the river Kopala chose me, as it chose Kopala before me, and so I am Kopala, and Kopala is me. Kopala is a languid little river that meanders down from the highlands, pausing for reflection in small lakes along the way. We are of a kind. I was meditating when its waters found me, creeping toward me, filling the little glade in which I sat. I opened my eyes and saw myself reflected in still waters, the river and I becoming one. There is no use in "what-ifs." I am a Shaper, and it is the only path I will ever know. I am proud to wear that mantle. I am the youngest of the Shapers, the least of the greatest of my people. I still have much to learn. My tribe depends on me. The other Shapers depend on me. Ixalan itself depends on me. That is why I am floating here, in the mystical waters of the Primal Wellspring, meditating. Tishana, my mentor, is here with me, guiding me, though her body is sitting in the canopy far above. #figure(image("004_The Shapers/02.jpg", width: 100%), caption: [Primal Wellspring | Art by John Avon], supplement: none, numbering: none) I can feel everything—the Great River, the Nine Tributaries, the swaying of the distant Deeproot Tree, the gentle motions of the tides and the winds. Emanating from a place that no living soul has seen, I feel the heartbeat of Ixalan, the steady thrum of the Golden City of Orazca. The power of Orazca is unlike any other. It is separate from the wind and the waves, the ephemeral exertions of life and the deep, slow grinding of the earth. It is many things to many people—its truths remain shrouded from our view. But what it #emph[is ] is beyond words. It is a steady pulse, a rhythm, that can be heard throughout the world by those who know how to listen. The pulse skips a beat. My eyes open. Then Tishana is there with me, guiding me back, reminding me wordlessly to #emph[see] the strangeness, to #emph[feel] it, to #emph[reflect] upon it—and, like water in the Great River, to let it flow over me, down the channel, to the sea, where all things must eventually return. My eyes close. We meditate further. I cannot help but wait in expectation of another missed beat. It does not come. Soon after, Tishana's presence wanes, and our meditation comes to an end. My eyes open, and my body returns to me. I swim down to the river bottom, kick off in a cloud of silt, and move from #emph[below] to #emph[above] . The air in the glade around the Wellspring is so humid I feel I hardly need my lungs, though of course the breath of mist that crosses my gills is not enough to sustain me. I breathe, in and out—a focus for meditation in the Sun Empire, I have heard. Our techniques, which must serve us both above and below, focus on the heartbeat. Tishana steps down a path of curving branches, which bend to deposit her gently on the bank. Her posture is stooped, her features wizened. She is the eldest of our people, old enough to remember when many of the trees in this glade were saplings. #figure(image("004_The Shapers/03.jpg", width: 100%), caption: [Tishana, Voice of Thunder | Art by <NAME>], supplement: none, numbering: none) "You felt it," she says. "Yes," I say. "What was it?" "A disturbance of the intangible," she says. "Like a dolphin trying to break through the riverwater's surface, although it cannot breach. I do not know what it means. But . . ." She pauses, giving me the chance to speak. When I first began training with Tishana, I had waited through these silences out of deference, but eventually, I realized that if she thought I knew the answer, her silence would continue indefinitely. "But it involves Orazca," I say. Orazca. The Golden City. The place our people have sworn to keep secret, even from ourselves. "And what involves Orazca involves the whole world," says Tishana. Tishana turns, and then I feel it too—a rush of magic from the north. A ripple moves through the jungle, a large group in motion, coming closer. Then they are at the edge of the glade, a group of about twenty River Heralds. They stand in formation, surrounding something I cannot see, guarding it. At their head stands Kumena, their Shaper. He is lean and lithe, with piercing eyes and a commanding attitude. The river Kumena runs rapid over jagged rocks. It is a vicious obstacle for our enemies, and a hazard even for us. The Shaper Kumena is no different, and he is perhaps the most powerful among us, save Tishana. "Shaper Tishana," he says, his voice booming through the clearing. He nods to me, as an afterthought. "Sh<NAME>." Tishana's people and mine, arrayed around the Wellspring, are watching and listening. Tishana inclines her head. I bow. "Shaper Kumena," says Tishana. "How fortunate that the Great River has brought you here." #figure(image("004_The Shapers/04.jpg", width: 100%), caption: [Overflowing Insight | Art by Lucas Graciano], supplement: none, numbering: none) "As it guides us all," says Kumena, automatically. There is no deference in his voice, to either the Great River that guides us or to the Shaper who leads us. "What brings you to the Wellspring, Shaper Kumena?" asks Tishana. Kumena points a finger at his people, and they part, revealing a bundle on the ground. No, not a bundle—a man. A soldier of the Sun Empire, bedraggled but whole, bound with a tangle of vines. His eyes are full of hatred. "I caught #emph[this] ," spits Kumena, "on the west side of the Great River, with a company of his fellows and their beasts. And you know what they were looking for." Tishana waves a hand. "They have long sought Orazca," she says. "One patrol on the far side of the river hardly means they have found it. Like the bloodsuckers, their zeal will not translate into success." Kumena turns to his captive. Their eyes lock, mutual hatred perfectly reflected in them. "Tell them what you told me." The man sneers, but speaks. I do not know what Kumena has done to him, or to his friends, but there is fear beneath the hatred. "Forces are converging on your Golden City," says the man. "Our spies tell us of two pirate captains . . . the stories are incredible, but they seem to be true. One is a man with the head of a bull. The other is a woman with hair like twisting vines who can kill with a glance. The woman has a device, a compass, that she says points the way to the Golden City. She was discussing it openly in their floating city." A murmur goes up among the assembled River Heralds. They have spies of their own, and had heard similar fears. But Kumena glowers at the man. "And?" he demands. The man flinches. "One of our own, a champion of the sun, performed a spell that revealed the Golden City," the man says. He cannot keep an edge of pride out of his voice. "She will go to its gates." Kumena spreads his arms wide, turning away from the man. "The situation has changed," he says. He is speaking to Tishana, but loudly—loud enough for everyone in the clearing to hear. "Orazca is threatened. You would have us protect it without even knowing where it is." Tishana's eyes narrow. She does not raise her voice, but it is louder than his. They call her the Voice of Thunder. Even her whispers can fell trees, if she wishes. She is letting a tiny gust of that power loose. "I would have us safeguard Orazca from all who would abuse it," says Tishana. "Even ourselves." "It's too late for that," says Kumena. "We already know that the bloodsuckers have a visionary guiding them. Now the beast-riders have one too, and the plunderers have this device. We are vastly outnumbered, and they are more zealous than ever. If this current keeps flowing, Orazca will be discovered." "And what would you have us do, <NAME>?" asks Tishana. "Please, grace us with your wisdom." Kumena swims in tumultuous waters and surely knows it. He presses on. "The time has come," says Kumena. "We must wield the power of the Immortal Sun ourselves, or we will see it fall into enemy hands. The sun will tumble from the sky, the waters will run cold, and this land that has cradled us will become our grave. Unless we act now, decisively. We have no choice!" The glade is silent. Tishana remains calm. She is firm, unafraid, unflinching. Another what-if crosses my mind. What if I were the one standing against Kumena? What if I must do so now? "Remind us, Kumena, why outsiders finding Orazca would be our doom." #figure(image("004_The Shapers/05.jpg", width: 100%), caption: [Spires of Orazca | Art by Yeong-Hao Han], supplement: none, numbering: none) Tishana's voice is only growing louder. Her eyes are stars, and her voice a crashing wave. I take a step back, but Kumena does not shrink away. "They would misuse it!" he hisses. "The Last Guardian entrusted it to #emph[us] , and if we let it fall into outsiders' hands, then we are derelict in our duty. They will destroy us and all the world with us!" "He entrusted us to keep it hidden," says Tishana, with the inevitability of a hurricane. "To keep it #emph[unused] , Kumena. You have forgotten your place. You have forgotten our duty." The water in the Wellspring has begun to swirl around Tishana. The air moves over my gills faster and faster. Now Kumena does step back, but he turns to the assembled Heralds. To me. "Surely you must see it!" he says, to me. "This philosophy of inaction is meaningless if the city becomes a weapon in the hands of our enemies! Will you help me defend our people?" He is staring at me. Tishana is looking at me too. My game of what-ifs must be spoken aloud. I know I must make the call, break the tie, be the deciding voice. A leader is decisive and just, and I must be so too. My words are like myself. Fluid and fair, even and just. "I cannot deny the truth in Kumena's words. If outsiders take the city, only misery can result. The Immortal Sun has brought ruin to this land once before, and we barely survived. For anyone to use it again would mean the end of everything we have built, and the failure of our vigil. "And yet. If the Last Guardian had meant for us to wield it, he could have entrusted it directly to our care. The history of the Immortal Sun is the history of its misuse by mortals. I am not so arrogant as to think that we alone might safely bear the weight of this responsibility. "Shaper Tishana is right," I say with confidence, "We must do everything in our power to prevent anyone from claiming the Golden City. That includes us. And I cannot trust anyone who is so eager to lay hands on such power." I feel my people's pride in my voice. I see Tishana's pride in her eyes. But I sense I have chosen the wrong side. Kumena's eyes flash, and then everything happens at once. Kumena waves a hand. The sun warrior is pulled beneath the surface of the Wellspring with a strangled cry. Kumena's people hang back, unwilling to join him in his rebellion. Tishana's people and mine rush into the glade. Wind and water swirl around us. Tishana suddenly stills, as does Kumena a moment later. I feel a tug at something in my chest: a connection, a spider-thread plucked like a bow. For a moment we all wait, sensing, knowing in our hearts that someone is approaching the shores. Tishana places her hand on the surface of the water. Her eyes snap open. "Vessels approach our coast. Kumena, if these are your interlopers—" Kumena scowls. "I will deal with them, but this strategy will not last us the next hundred years. It will not last us one. You have all been warned." Kumena speaks one last word, and a shell of water and vines springs into existence around him. There's a flash of magic, a swirl of water, and then he is gone from the glade, rushing through the jungle in a wave of tangled roots and rushing current. I reach beneath the surface with my magic, looking for the sun warrior, but his body is still and waterlogged. "Is he headed for Orazca?" Tishana shakes her head. "If Kumena could find Orazca on his own, I think he would have done so already," she says. "And even if he can, he will seek to hobble his rivals first." "You think he will seek out these others who seem to know the way," I say. "Yes," says Tishana. "I'm going after him." "You? But Shaper, you are—" "Old," she says, with a twinkle in her eye. "I know. But I'm not decrepit, <NAME>. Not yet. I will go. Only I can hope to overpower him." "I'll go with you," I say. "Stay here," says Tishana. "I need you to rally our people and be ready to move. If Kumena takes Orazca—if anyone does—it may take all of us to win it back." #figure(image("004_The Shapers/06.jpg", width: 100%), caption: [Shapers' Sanctuary | Art by Zezhou Chen], supplement: none, numbering: none) "No," I say. "Shaper, please. You have kept it secret for a reason." Tishana lays a hand on my shoulder. "Kumena is right about one thing," she says. "I do not think we can keep the Golden City hidden any longer. And if we cannot keep it hidden, then we must hope the Great River will grant us all the wisdom to guard the city without using its power." "Wisdom that one of the greatest among us lacks," I say. "I cannot bring myself to call that hope." "Call it what you will," she says. "We have a way forward and a current at our backs." Then water and vines envelop her, the trees bend in deference to let her pass, and she is gone. Our people are looking to me. "Rest," I say. "Meditate upon what has happened here. In the morning, I will send messengers to all the tribes. We will do as Shaper Tishana says." Most of them murmur agreement. Some grumble. Kumena's people have already slipped away. Beneath me, I let the roots and vines gather up the body of the sun warrior and pull him beneath the bottom of the pool to rest, and to nourish the trees that grow here. It is not the end he would have hoped for, but it is the best I can do. I sink beneath the surface of the Wellspring. I can feel everything—the Great River, the Nine Tributaries, the swaying of the distant Deeproot Tree. Our two greatest champions race away from me, bending the jungle away before them and replacing it behind them, heading east. What if I had joined my mentor? What if she fails? #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) = TISHANA Wind whips at the membranes of my fins and the redolence of low tide curls my toes as I approach the one student I failed the most. I track Kumena quickly, simply—a straight line from where we #emph[were] to where we #emph[are] . Kumena's immaturity is as plain as his ego. He is a powerful Shaper, yes, but he is artless, naive, as impetuous as his namesake. At their best, those chosen to bear the name of Kumena are freewheeling, passionate, biased toward action. This Kumena is all of these things, but with a sharp edge that makes him dangerous. When he was my student, he tested every boundary. I have fond memories of most of my students, but my memories of him are brimming with headaches and resentment. I would not go so far as to say I failed as a mentor, but rather that I succeeded only as much as one could have. Maturity cannot be taught; it must be developed. In front of me spreads the great expanse of the ocean. It is beautiful, baleful, avoided—our preferred waters are murky and fresh and without the harsh salt of the coast. He stands in front of me, arms raised, agitating the sky and the waves into a frothy roil. "We can conjure a thousand storms a thousand times, or we can raise a city only once," Kumena says over the roar of the sea. "Which is the better expenditure of our energy? Which is better #emph[stewardship] , Tishana?" "Awakening Orazca is not an option." I subsume his spell with magic of mine own. My waves pull the enemy ships close, and my rain slaps their sails. #figure(image("004_The Shapers/07.jpg", width: 100%), caption: [River's Rebuke | Art by Raymond Swanland], supplement: none, numbering: none) "I will not let you imperil more lives. I will not let you answer contingencies with contingencies and outrages with outrages." I sense him slip out of the spell, step back, look onward with awe at how my magic now tumbles the ships in the distance like leaves on a whitewater river. "You always had more skill than I," he says, hushed. I ram one of the ships into the side of a sea stack. "You think yourself wiser than your elders," I say. "That will be your downfall." "And your age will be yours." I look over my shoulder just in time to see Kumena's fist hit my face. And all goes dark.
https://github.com/JosephBoom02/Appunti
https://raw.githubusercontent.com/JosephBoom02/Appunti/main/Anno_2_Semestre_2/Teoria_Elettrotecnica/teoria.typ
typst
#let title = "Domande di Teoria Elettrotecnica" #let author = "<NAME>" #set document(title: title, author: author) //Code to have bigger fraction in inline math #let dfrac(x,y) = math.display(math.frac(x,y)) #set par(justify: true, leading: 0.9em) //Shortcut for centered figure with image #let cfigure(img, wth) = figure(image(img, width: wth)) = Teorema di Tellegen (01/06/2022) Si consideri una rete elettrica con $l$ tensioni di lato ed $l$ correnti di lato che soddisfino le #underline[leggi di Kirchhoff]. Si ha che $underline(sum_(k=1)^(l) v_k i_k=0)$ Se $underline(v)$ e $underline(i)$ rappresentano le tensioni e le corrispondenti correnti di lato in uno stesso istante, si ha che il teorema di Tellegen si riduce al principio #underline[di conservazione] delle #underline[potenze istantanee]. È possibile esprimere la potenza #underline[erogata] dai bipoli attivi come $sum_(h=1)^M P_h$ dove M è il numero di componenti che rispettano la convenzione #underline[del generatore], e la potenza #underline[assorbita] dai bipoli passivi come $sum_(j=1)^N P_j$ dove N è il numero di componenti che rispettano la convenzione #underline[dell' utilizzatore]. In questo caso il teorema di Tellegen afferma che la #underline[sommatoria] delle potenze elettriche #underline[generate] dai bipoli attivi è pari a quella delle potenze elettriche #underline[assorbite] dai bipoli passivi come descritto da $underline(sum_(h=1)^M P_h = sum_(j=1)^N P_j)$. = Teorema del massimo trasferimento di potenza attiva su un bipolo (11/06/2022) #cfigure("Teorema_potenza.png", 30%) È data una sorgente di alimentazione sinusoidale (bipolo) e si vuole determinare qual è il valore dell'impedenza $overline(Z) = R + j X$ di carico tale da estrarre la massima potenza attiva dalla sorgente. La potenza attiva #underline[assorbita] dall'impedenza di carico $overline(Z)$ può essere espressa nella forma $underline(P = R I^2)$. Si rappresenta la sorgente con un bipolo Thevenin.\ N.B. $(overline(V)_0, overline(Z)_0 = R_0 + j X_0)$. \ Il quadrato del valore efficacie della corrente che circola nell'impedenza vale $underline(I^2 = frac(V_0^2, (R+R_0)^2 + (plus.minus X plus.minus X_0)^2) )$. La corrente, e quindi la potenza attiva, può essere dapprima massimizzata minimizzando la reattanza complessiva, ovvero quando $underline(X = -X_0)$. La potenza attiva assorbita dall'impedenza risulta quindi $underline( P = frac(R V_0^2,(R+R_0)^2) )$. La massimizzazione complessiva può essere ottenuta applicando il teorema di trasferimento della massima potenza valido per una rete algebrica. Il valore della resistenza $R$ risulta quindi $underline( R = R_0 )$. Si ha pertanto che il valore dell'impedenza $overline(Z)$ tale da estrarre la massima potenza risulta $underline( overline(Z) = overline(Z)_0^convolve )$. = Circuiti dinamici del secondo ordine (05/07/2022) Sia dato un circuito dinamico del secondo ordine. Per determinare la soluzione associata all'equazione omogenea si introduce #underline[il polinomio caratteristico] dell'equazione #underline[differenziale] di #underline[secondo] grado. Si distinguono tre casi caratterizzati da valore positivo negativo o nullo del #underline[discriminante] $Delta = underline( alpha^2 - omega_0^2 )$ dove $alpha$ è il #underline[coefficiente di smorzamento] e $omega_0$ è #underline[la pulsazione di risonanza].\ Se $Delta > 0$ avremo due soluzioni #underline[reali distinte] e il circuito si dice #underline[sovrasmorzato]. Se $Delta < 0$ avremo due soluzioni #underline[complesse coniugate] ed il circuito si dice #underline[sottosmorzato]. Infine se $Delta = 0$ avremo due soluzioni #underline[reali coincidenti] ed il circuito si dice #underline[criticamente smorzato].\ Dato un circuito RLC serie $alpha$ è pari a $underline( frac(R,2L) )$ e $omega_0$ è uguale a $underline( frac(1, L C) )$. = Il trasformatore (09/09/2022) Il trasformatore è costituito da un nucleo di materiale #underline[ferromagnetico] su cui sono avvolti #underline[due avvolgimenti]: il primario, costituito da $n_1$ spire ed il secondario, costituito da $n_2$ spire. Quando il primario è alimentato con una tensione $v_1$ ("tensione primaria"), #underline[alternata], ai capi dell'avvolgimento secondario si manifesta una tensione $v_2$ ("tensione secondaria"), #underline[isofrequenziale] con la tensione primaria. La tensione $v_2$ è generata da una fem #underline[trasformatorica].\ Se il secondario è chiuso su di un carico elettrico, il primario #underline[eroga] la corrente $i_1$ ("corrente primaria"), ed il secondario #underline[assorbe] la corrente $i_2$ (corrente secondaria), entrambe le correnti sono alternate, #underline[isofrequenziali] con le tensioni.\ Mediante il trasformatore è quindi possibile trasferire potenza elettrica dall'avvolgimento primario a quello secondario, senza fare ricorso ad alcun collegamento #underline[elettrico] tra i due avvolgimenti; il trasferimento di potenza avviene invece attraverso #underline[il campo magnetico] che è presente principalmente nel nucleo del trasformatore e che è in grado di scambiare energia con entrambi i circuiti.\ Facendo riferimento ai versi positivi per le correnti e per i flussi mostrati nella figura di sopra, il flusso totale concatenato con l'avvolgimento 1 $(phi_(c_1))$ ed il flusso totale concatenato con l'avvolgimento 2 $(phi_(c_2))$ risultano rispettivamente $phi_(c_1) = n_1 phi + phi_(d_1)$ e $phi_(c_2) = -n_2 phi + phi_(d_2)$ dove $phi$ è il #underline[flusso "principale"] mentre $phi_(d_1)$ e $phi_(d_2)$ e sono flussi “dispersi” concatenati rispettivamente con l'intero avvolgimento 1 e con l'intero avvolgimento 2.\ Tenendo in considerazione la #underline[caduta di tensione ohmica], sugli avvolgimenti si ha che la tensione ai capi del primario e quella ai capi del secondario sono rispettivamente pari a $underline( v_1(t) = frac( d phi_(c_1), d t ) + R_1 i_1 = n_1 frac( d phi, d t ) + frac( d phi_(d_1), d t ) + R_1 i_1 )$ e $underline( v_2(t) = - frac( d phi_(c_2), d t ) - R_2 i_2 = n_2 frac( d phi, d t ) - frac( d phi_(d_2), d t ) - R_2 i_2 )$. = Rifasamento in monofase (22/07/2022) Dato un sistema monofase alimentato da un generatore $e(t)$ e collegato ad un utilizzatore avente impedenza $overline(Z)_U$ (carico elettrico normalmente di tipo #underline[induttivo] con $overline(I)_L = overline(I)_U )$, la linea può essere schematizzata tramite un'impedenza $underline( overline(Z)_L = R_L + j omega L )$. A causa della caduta di tensione su tale impedenza la tensione sul carico non è uguale a quella generata ma varia in funzione del carico stesso.\ Alla resistenza di linea è associata una potenza elettrica dissipata per effetto joule pari a $underline( P_d = R_L I_L^2 )$.\ Applicando la #underline[legge di Kirchhoff delle tensioni], la tensione applicata ai capi del carico risulta essere $underline( overline(V) = overline(E) - overline(Z)_L overline(I)_L )$. La potenza attiva assorbita dal carico viene definita come $underline(P = V I_L cos(phi))$, di conseguenza la corrente di linea viene espressa come $underline( I_L = frac(P, V cos(phi)) )$. Tale corrente può essere ridotta aumentando la tensione sul carico, riducendo la potenza attiva assorbita dal carico o #underline[aumentando] il $underline( cos(phi) )$, ovvero riducendo l'angolo di sfasamento tra tensione e corrente. Questo fa sì che corrente tensione relativi al carico siano maggiormente in #underline[fase].\ Per ridurre lo sfasamento è possibile introdurre un #underline[condensatore] in #underline[parallelo] al carico. La potenza #underline[reattiva] iniettata è di segno #underline[negativo], portando di conseguenza a diminuire la potenza #underline[apparente] del generatore. La corrente di linea risulta quindi pari a $underline( overline(I)'_L = overline(I)_U + overline(I)_C )$ di modulo #underline[inferiore] rispetto al caso privo di rifasamento.
https://github.com/frectonz/the-pg-book
https://raw.githubusercontent.com/frectonz/the-pg-book/main/book/133.%20tablets.html.typ
typst
tablets.html Tablets December 2010I was thinking recently how inconvenient it was not to have a general term for iPhones, iPads, and the corresponding things running Android. The closest to a general term seems to be "mobile devices," but that (a) applies to any mobile phone, and (b) doesn't really capture what's distinctive about the iPad.After a few seconds it struck me that what we'll end up calling these things is tablets. The only reason we even consider calling them "mobile devices" is that the iPhone preceded the iPad. If the iPad had come first, we wouldn't think of the iPhone as a phone; we'd think of it as a tablet small enough to hold up to your ear.The iPhone isn't so much a phone as a replacement for a phone. That's an important distinction, because it's an early instance of what will become a common pattern. Many if not most of the special-purpose objects around us are going to be replaced by apps running on tablets.This is already clear in cases like GPSes, music players, and cameras. But I think it will surprise people how many things are going to get replaced. We funded one startup that's replacing keys. The fact that you can change font sizes easily means the iPad effectively replaces reading glasses. I wouldn't be surprised if by playing some clever tricks with the accelerometer you could even replace the bathroom scale.The advantages of doing things in software on a single device are so great that everything that can get turned into software will. So for the next couple years, a good recipe for startups will be to look around you for things that people haven't realized yet can be made unnecessary by a tablet app.In 1938 <NAME> coined the term ephemeralization to describe the increasing tendency of physical machinery to be replaced by what we would now call software. The reason tablets are going to take over the world is not (just) that <NAME> and Co are industrial design wizards, but because they have this force behind them. The iPhone and the iPad have effectively drilled a hole that will allow ephemeralization to flow into a lot of new areas. No one who has studied the history of technology would want to underestimate the power of that force.I worry about the power Apple could have with this force behind them. I don't want to see another era of client monoculture like the Microsoft one in the 80s and 90s. But if ephemeralization is one of the main forces driving the spread of tablets, that suggests a way to compete with Apple: be a better platform for it.It has turned out to be a great thing that Apple tablets have accelerometers in them. Developers have used the accelerometer in ways Apple could never have imagined. That's the nature of platforms. The more versatile the tool, the less you can predict how people will use it. So tablet makers should be thinking: what else can we put in there? Not merely hardware, but software too. What else can we give developers access to? Give hackers an inch and they'll take you a mile. Thanks to <NAME>, <NAME>, <NAME>, and <NAME> for reading drafts of this.
https://github.com/txtxj/Formal-Methods-Typst
https://raw.githubusercontent.com/txtxj/Formal-Methods-Typst/main/README.md
markdown
# Formal-Methods-Typst 用于书写形式化中数理逻辑证明题 样例: ``` #proof( $q->r$, [p], // premise 的缩写形式 [p] [+], 5, // 建立一个持续 5 行的 assuption $p->q$, [a], // assumption 的缩写形式 [a] [+], 3, // 建立一个持续 3 行的 assuption $p$, [a], $q$, [$-> e$ 2,3], $r$, [$-> e$ 1,4], $p->r$, [$-> i$ 3-5], $(p->q)->(p->r)$, [$-> i$ 2-6], ) ``` ![](sample_1.png) ``` #proof( $exists x(S->Q(x))$, [p], [+], 5, $S$, [a], [+], 3, $x_0$, [x], // 建立一个任意变量 x_0,该变量的声明将和下一行一起显示 $S->Q(x_0)$, [a], $Q(x_0)$, [$-> e$ 3,2], $exists x Q(x)$, [$exists x space i$ 4], $exists x Q(x)$, [$exists x space e$ 1,3-5], $S->exists x Q(x)$, [$-> i$ 2,6] ) ``` ![](sample_2.png) ## 使用方法 基础用法: ``` #proof($公式1$, [规则1], $公式2$, [规则2], $公式3$, [规则3], ...) ``` 规则简写: ``` [p] = premise [a] = assumption [x] = new variable ``` 其他简写: ``` [+] = new block ``` 定义一个 assumption 块(作用域): ``` #proof( ... [+], 作用域大小, $作用域中的公式1$, [作用域中的规则1], ... ) ``` 定义一个变量,并令该变量的声明和公式 n 处于同一行: ``` #proof( ... $变量名$, [x], $公式n$, [规则n], ... ) ``` 定义一个变量,该变量的声明位于单独一行: ``` #proof( ... $变量名$, [x], $$, [], ... ) ``` **Warning: 不支持换页排版,请自行换页**
https://github.com/soul667/typst
https://raw.githubusercontent.com/soul667/typst/main/PPT/MATLAB/touying/themes/university.typ
typst
// University theme // Originally contributed by <NAME> - https://github.com/drupol #import "../utils/utils.typ" #import "../utils/states.typ" #import "../utils/components.typ" #let slide( self: none, title: none, subtitle: none, header: none, footer: auto, ..args, ) = { if title != auto { self.uni-title = title } self.uni-header = self => { if header != none { header } else if title != none { block(inset: (x: .5em), grid( columns: 1, gutter: .3em, grid( columns: (auto, 1fr, auto), align(top + left, heading(level: 2, text(fill: self.colors.primary, title))), [], align(top + right, text(fill: self.colors.primary.lighten(65%), states.current-section-title)) ), text(fill: self.colors.primary.lighten(65%), size: .8em, subtitle) ) ) } } if footer != auto { self.uni-footer = footer } (self.methods.touying-slide)( ..args.named(), self: self, setting: body => { show: args.named().at("setting", default: body => body) body }, ..args.pos(), ) } #let title-slide( self: none, logo: none, ..args, ) = { self = utils.empty-page(self) let info = self.info + args.named() info.authors = { let authors = if "authors" in info { info.authors } else { info.author } if type(authors) == array { authors } else { (authors,) } } let content = { if logo != none { align(right, logo) } align(center + horizon, { block( inset: 0em, breakable: false, { text(size: 2em, fill: self.colors.primary, strong(info.title)) if info.subtitle != none { parbreak() text(size: 1.2em, fill: self.colors.primary, info.subtitle) } } ) set text(size: .8em) grid( columns: (1fr,) * calc.min(info.authors.len(), 3), column-gutter: 1em, row-gutter: 1em, ..info.authors.map(author => text(fill: black, author)) ) v(1em) if info.institution != none { parbreak() text(size: .9em, info.institution) } if info.date != none { parbreak() text(size: .8em, if type(info.date) == datetime { info.date.display(self.datetime-format) } else { info.date }) } }) } (self.methods.touying-slide)(self: self, repeat: none, content) } #let focus-slide(self: none, background-color: none, background-img: none, body) = { let background-color = if background-img == none and background-color == none { rgb(self.colors.primary) } else { background-color } self = utils.empty-page(self) self.page-args = self.page-args + ( fill: self.colors.primary-dark, margin: 1em, ..(if background-color != none { (fill: background-color) }), ..(if background-img != none { (background: { set image(fit: "stretch", width: 100%, height: 100%) background-img }) }), ) set text(fill: white, size: 2em) (self.methods.touying-slide)(self: self, repeat: none, align(horizon, body)) } #let matrix-slide(self: none, columns: none, rows: none, ..bodies) = { self = utils.empty-page(self) (self.methods.touying-slide)(self: self, composer: (..bodies) => { let bodies = bodies.pos() let columns = if type(columns) == int { (1fr,) * columns } else if columns == none { (1fr,) * bodies.len() } else { columns } let num-cols = columns.len() let rows = if type(rows) == int { (1fr,) * rows } else if rows == none { let quotient = calc.quo(bodies.len(), num-cols) let correction = if calc.rem(bodies.len(), num-cols) == 0 { 0 } else { 1 } (1fr,) * (quotient + correction) } else { rows } let num-rows = rows.len() if num-rows * num-cols < bodies.len() { panic("number of rows (" + str(num-rows) + ") * number of columns (" + str(num-cols) + ") must at least be number of content arguments (" + str(bodies.len()) + ")") } let cart-idx(i) = (calc.quo(i, num-cols), calc.rem(i, num-cols)) let color-body(idx-body) = { let (idx, body) = idx-body let (row, col) = cart-idx(idx) let color = if calc.even(row + col) { white } else { silver } set align(center + horizon) rect(inset: .5em, width: 100%, height: 100%, fill: color, body) } let content = grid( columns: columns, rows: rows, gutter: 0pt, ..bodies.enumerate().map(color-body) ) content }, ..bodies) } #let slides(self: none, title-slide: true, slide-level: 1, ..args) = { if title-slide { (self.methods.title-slide)(self: self) } (self.methods.touying-slides)(self: self, slide-level: slide-level, ..args) } #let register( aspect-ratio: "16-9", progress-bar: true, self, ) = { // color theme self = (self.methods.colors)( self: self, primary: rgb("#04364A"), secondary: rgb("#176B87"), tertiary: rgb("#448C95"), ) // save the variables for later use self.uni-enable-progress-bar = progress-bar self.uni-progress-bar = self => states.touying-progress(ratio => { grid( columns: (ratio * 100%, 1fr), rows: 2pt, components.cell(fill: self.colors.primary), components.cell(fill: self.colors.secondary) ) }) self.uni-header = none self.uni-footer = self => { let cell(fill: none, it) = rect( width: 100%, height: 100%, inset: 1mm, outset: 0mm, fill: fill, stroke: none, align(horizon, text(fill: white, it)) ) show: block.with(width: 100%, height: auto, fill: self.colors.secondary) grid( columns: (25%, 1fr, 15%, 10%), rows: (1.5em, auto), cell(fill: self.colors.primary, self.info.author), cell(fill: self.colors.secondary, if self.info.short-title == auto { self.info.title } else { self.info.short-title }), cell(fill: self.colors.tertiary, if type(self.info.date) == datetime { self.info.date.display(self.datetime-format) } else { self.info.date }), cell(fill: self.colors.tertiary, states.slide-counter.display() + [~/~] + states.last-slide-number) ) } // set page let header(self) = { set align(top) grid( rows: (auto, auto), row-gutter: 3mm, if self.uni-enable-progress-bar { utils.call-or-display(self, self.uni-progress-bar) }, utils.call-or-display(self, self.uni-header), ) } let footer(self) = { set text(size: .4em) set align(center + bottom) utils.call-or-display(self, self.uni-footer) } self.page-args = self.page-args + ( paper: "presentation-" + aspect-ratio, header: header, footer: footer, margin: (top: 2.5em, bottom: 1em, x: 0em), ) self.padding = (x: 2em, y: 0em) // register methods self.methods.slide = slide self.methods.title-slide = title-slide self.methods.focus-slide = focus-slide self.methods.matrix-slide = matrix-slide self.methods.slides = slides self.methods.touying-outline = (self: none, enum-args: (:), ..args) => { states.touying-outline(enum-args: (tight: false,) + enum-args, ..args) } self.methods.alert = (self: none, it) => text(fill: self.colors.primary, it) self.methods.init = (self: none, body) => { set text(size: 25pt) show footnote.entry: set text(size: .6em) body } self }
https://github.com/Error-418-SWE/Documenti
https://raw.githubusercontent.com/Error-418-SWE/Documenti/src/2%20-%20RTB/Documentazione%20esterna/Piano%20di%20Progetto/Piano%20di%20Progetto.typ
typst
#import "@preview/cetz:0.2.0": * #import chart #import "/template.typ": * #show: project.with( title: "Piano di Progetto", subTitle: "Pianificazione, analisi e retrospettive", authors: ( "<NAME>", "<NAME>", "<NAME>", "<NAME>", "<NAME>", ), showLog: true, showImagesIndex: false, isExternalUse: true, ); #show regex("€ (\d)+"): it => { it ",00" } #show regex("\(-(\d)+\)"): it => { text(it, fill: green) } #show regex("\(\+(\d)+\)"): it => { text(it, fill: red) } #let roles = ("Responsabile", "Amministratore", "Analista", "Progettista", "Programmatore", "Verificatore") #let pal = (red, blue, yellow, olive, orange, aqua, eastern, maroon, fuchsia, green) #let roles-legend = rect(stroke: 0.5pt + luma(140))[ #let tuples = roles.zip(pal) #stack( spacing: 0.75em, dir: ltr, ..tuples.map(tuple => stack( dir: ltr, spacing: 0.25em, rect(stroke: 0.75pt, fill: tuple.at(1), width: 0.75em, height: 0.75em), tuple.at(0) )) ) ] #let p = palette.new(colors: pal) #let role-chart-size = (8, 7) #let barchart-config = ( size: role-chart-size, mode: "clustered", value-key: (1,2), bar-style: p, legend: "legend.north", legend-style: (orientation: ltr, spacing: 0.5, padding: 0.5em, stroke: 0.5pt + luma(140), item: (spacing: 0.5)), x-label: "Ore", x-tick-step: none, labels: ("Preventivate", "Effettive") ) #let barchart-label-config = ( anchor: "west", padding: .2 ) #let piechart-config = ( radius: 2, inner-radius: 1, gap: 1deg, slice-style: p, label-key: (0), value-key: (1), outer-label: (content: "%"), ) #let getMaxFromPlotData(data) = { let max = 0 for datum in data { if calc.max(..datum.slice(1)) > max { max = calc.max(..datum.slice(1)) } } return max } #let compute-labels-x-coordinate(data, role-chart-size) = { let i = 0 let x-coordinates = () let max = getMaxFromPlotData(data) while(i < data.len()) { x-coordinates.push((data.at(i).at(1)*role-chart-size.at(0)/max, data.at(i).at(2)*role-chart-size.at(0)/max)) i += 1 } return x-coordinates } #let compute-labels-y-coordinate(data, role-chart-size) = { let i = 0 let y-coordinates = () while(i < data.len()) { y-coordinates.push(((role-chart-size.at(1) - 0.77 - i), (role-chart-size.at(1) - 1.17 - i))) i += 1 } return y-coordinates } #outline( title: "Indice dei grafici", target: figure.where(kind: "chart") ) #pagebreak() = Introduzione == Scopo del documento Il documento _Piano di progetto_ ha il compito di governare la pianificazione dell'avanzamento del progetto, determinando task e obiettivi da raggiungere e presentando un'analisi critica del lavoro fino a quel momento svolto. L'intento è rendicontare e valutare criticamente l'operato compiuto per migliorarlo, ove necessario, e gestire in modo efficace ed efficiente le risorse. Il documento si articola in 5 sezioni principali: - *Panoramica generale*: dedicata all'analisi preventiva dei costi complessivi di realizzazione; - *Periodi di sviluppo*: dedicata all'analisi della suddivisione temporale dello sviluppo del progetto; - *Pianificazione del lavoro*: dedicata alla descrizione della metodologia di lavoro adottata; - *Preventivi di periodo*: dedicata alla pianificazione delle attività da svolgere per ciascuno sprint; - *Consuntivi di periodo*: dedicata all'analisi retrospettiva del lavoro svolto in ciascuno sprint. Riporta eventuali criticità ed azioni intraprese a fini migliorativi. == Glossario #glo_paragrafo == Riferimenti <riferimenti> === Riferimenti a documentazione interna <riferimenti-interni> - Documento #glo_v: \ _#link("https://github.com/Error-418-SWE/Documenti/blob/main/2%20-%20RTB/Glossario_v" + glo_vo + ".pdf")_ #lastVisitedOn(13,02,2024) - Documento #ris_v: \ _#link("https://github.com/Error-418-SWE/Documenti/blob/main/2%20-%20RTB/Documentazione%20interna/Analisi%20dei%20Rischi_v" + ris_vo + ".pdf")_ #lastVisitedOn(13,02,2024) === Riferimenti normativi <riferimenti-normativi> - Regolamento di progetto: \ _#link("https://www.math.unipd.it/~tullio/IS-1/2023/Dispense/PD2.pdf")_ #lastVisitedOn(13,02,2024) - Gestione di progetto: \ _#link("https://www.math.unipd.it/~tullio/IS-1/2023/Dispense/T4.pdf")_ #lastVisitedOn(13,02,2024) - I processi di ciclo di vita del software: \ _#link("https://www.math.unipd.it/~tullio/IS-1/2023/Dispense/T2.pdf")_ #lastVisitedOn(13,02,2024) === Riferimenti informativi <riferimenti-informativi> - Capitolato "Warehouse Management 3D" (C5) di _Sanmarco Informatica S.p.A._: \ _#link("https://www.math.unipd.it/~tullio/IS-1/2023/Progetto/C5.pdf")_ #lastVisitedOn(13, 02, 2024) #pagebreak() = Panoramica generale Identificati i rischi, le relative contromisure e il calendario di progetto, è stato definito, mediante una pianificazione a ritroso, un preventivo iniziale dei costi di realizzazione del progetto. È corretto evidenziare come i membri del gruppo non siano dotati di esperienza sufficiente per fornire un preventivo corretto e preciso sin dagli inizi dello sviluppo: per tale motivo, il prezzo indicato sarà soggetto a modifiche con l'avanzamento del progetto (seppur mai superando il prezzo preventivato in candidatura). == Rischi e loro mitigazione Il documento Analisi dei Rischi (v2.0.0), riportato in @riferimenti-interni, elenca e categorizza i rischi, li analizza e fornisce strumenti di monitoraggio e mitigazione. == Prospetto orario complessivo <prospetto-orario-complessivo> La ripartizione delle ore tiene conto degli obiettivi disciplinari di sviluppo di competenze trasversali nei vari ruoli presenti all'interno del progetto. #figure( table( columns: 8, [*Membro*],[*Responsabile*],[*Amministratore*],[*Analista*],[*Progettista*],[*Programmatore*],[*Verificatore*],[*Totale*], [Banzato], [10], [14], [15], [7], [28], [21], [95], [Oseliero], [10], [14], [15], [7], [28], [21], [95], [Gardin], [10], [14], [15], [7], [28], [21], [95], [Todesco], [10], [14], [15], [7], [28], [21], [95], [Carraro], [10], [14], [15], [7], [28], [21], [95], [Zaccone], [10], [14], [15], [7], [28], [21], [95], [Nardo], [10], [14], [15], [7], [28], [21], [95], [Totale ore], [91], [70], [70], [98], [210], [126], [665], [Costo\ orario], [€ 30], [€ 20], [€ 25], [€ 25], [€ 15], [€ 15], [/], [Costo\ ruolo], [€ 2100], [€ 1960], [€ 2625], [€ 1225], [€ 2940], [€ 2205], [€ 13055], ), caption: "Prospetto orario complessivo per membro e ruolo" ) #let data = ( ("Responsabile", 10), ("Amministratore", 14), ("Analista", 15), ("Progettista", 7), ("Programmatore", 28), ("Verificatore", 21), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo (complessiva)", kind: "chart", supplement: "Grafico" ) == Preventivo calcolato Il costo totale preventivato è di € 13055. == Analisi dei ruoli === Responsabile Il Responsabile è un ruolo presente durante l'intero progetto. Il suo compito è quello di gestire il gruppo e di assicurarsi che lo sviluppo proceda secondo le tempistiche predefinite e le aspettative del Committente. Deve inoltre redigere e far rispettare le Norme di Progetto, nonché le linee guida di sviluppo che l'intero gruppo deve rispettare. Essendo il ruolo più costoso, il numero di ore è stato scelto per favorire l'efficienza e non pesare eccessivamente sul costo finale. === Amministratore L'Amministratore è un ruolo presente durante l'intero progetto, in quanto si occupa di predisporre e controllare il corretto utilizzo delle procedure e degli strumenti definiti nelle Norme di Progetto, andando anche a gestire e implementare automatismi, migliorando così l'efficienza del gruppo. Il monte ore scelto è tale, poiché essendo questo un ruolo di controllo, non sono richieste un numero elevato di ore. === Analista L'Analista è il ruolo preposto all'individuazione, redazione, aggiornamento e tracciamento dei requisiti del progetto. Il modello Agile adottato dal gruppo prevede che l'attività di analisi si svolga in modo incrementale, seppur preminente inizialmente, che permetterà la redazione del documento Analisi dei Requisiti ai fini della _Requirements and Technology Baseline_. Pertanto, per il ruolo di Analista il gruppo riserva un numero di ore durante il periodo PB qualora si necessitasse di rivedere o aggiornare i requisiti individuati. === Progettista Il Progettista ha il compito di delineare e documentare l'architettura del prodotto in modo da: - soddisfare i requisiti raccolti nelle fasi pregresse; - aiutare il gruppo di sviluppo con una documentazione chiara ed esaustiva. Nello stabilire l'architettura deve quindi indicare anche quali saranno le tecnologie da utilizzare per la sua implementazione. Ritenendolo un ruolo impegnativo dal punto di vista temporale, il numero di ore risulta maggiore rispetto ai ruoli precedenti. === Programmatore Il Programmatore ha il compito di tradurre in codice eseguibile l'architettura prodotta dal progettista. Il ruolo prevede un numero di ore molto elevato poiché riteniamo il lavoro più dispendioso a livello temporale rispetto a quello delle altre figure professionali. === Verificatore Il Verificatore è un ruolo presente durante l'intero progetto, che si occupa di mantenere degli standard qualitativi sul lavoro del gruppo: egli deve verificare la correttezza, esaustività e coerenza di tutti i documenti, e nella fase di codifica sarà colui che si occuperà di controllare la qualità del software prodotto. Proprio per questo il totale delle ore risulta essere il secondo più elevato dopo il Programmatore. #pagebreak() = Periodi di sviluppo == Introduzione Il periodo compreso tra l'aggiudicazione del capitolato e la data di consegna del prodotto viene suddiviso in 2 periodi principali dettati dalle revisioni esterne _Requirements and Technology Baseline (RTB)_ e _Product Baseline (PB)_, rispettivamente previste per il 27-01-2024 e il 20-03-2024.\ Vengono pertanto a definirsi i seguenti periodi di sviluppo: - *Periodo RTB*: dal 06-11-2023 al 26-01-2024; - *Periodo PB*: dal 27-01-2024 al 20-03-2024. Risulta ragionevole considerare il periodo di PB maggiormente impegnativo e durante il quale si svolgerà la maggior parte delle ore di lavoro, complici la fine delle lezioni universitarie, il termine della sessione invernale d'esami e l'assenza di festività. Per questo motivo, il gruppo _Error\_418_ ha deciso di suddividere le ore di lavoro in modo da svolgere il 65% delle ore totali durante il periodo PB e il restante 35% durante il periodo RTB. #grid( columns: (1fr, 1fr), [ #set align(bottom) #figure( table( columns: 3, [*Periodo*], [*Ore*], [*Percentuale*], [RTB], [231], [35%], [PB], [434], [65%], [Totale], [665], [100%] ), caption: "Suddivisione oraria per periodo" ) ], [ #set align(center) #rect(stroke: 0.5pt + luma(140))[ #let tuples = ("RTB", "PB").zip(pal) #stack( spacing: 0.75em, dir: ltr, ..tuples.map(tuple => stack( dir: ltr, spacing: 0.25em, rect(stroke: 0.75pt, fill: tuple.at(1), width: 0.75em, height: 0.75em), tuple.at(0) )) ) ] #let data = ( ("RTB", 231), ("PB", 434), ) #figure({ canvas({ import draw: * chart.piechart(..piechart-config, radius: 1.5, inner-radius: 0.75, data)} )}, caption: "Suddivisione oraria per periodo", kind: "chart", supplement: "Grafico" ) ] ) == Periodo RTB - Periodo: dal 06-11-2023 al 26-01-2024 (56 giorni lavorativi); - Obiettivi di periodo: - Analisi dei Requisiti; - Esplorazione e definizione dei domini tecnologico e applicativo; - Produzione del Proof of Concept (PoC); - Redazione documentazione relativa al periodo. #roles-legend #grid( columns: (1fr, 1fr), [ #set align(bottom) #figure( caption: "Suddivisione oraria per ruolo (RTB)", table( columns: 2, [*Ruolo*], [*Ore*], [Responsabile], [28], [Amministratore], [42], [Analista], [70], [Progettista], [14], [Programmatore], [28], [Verificatore], [49], [Totale], [231], ) ) ], [ #let data = ( ("Responsabile", 28), ("Amministratore", 42), ("Analista", 70), ("Progettista", 14), ("Programmatore", 28), ("Verificatore", 49), ) #figure({ canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo (RTB)", kind: "chart", supplement: "Grafico" ) ] ) == Periodo PB - Periodo: dal 27-01-2024 al 20-03-2024 (38 giorni lavorativi); - Obiettivi di periodo: - Scelte architetturali e di design; - Implementazione del prodotto; - Verifica, test e validazione del prodotto; - Redazione documentazione relativa al periodo. #roles-legend #grid( columns: (1fr, 1fr), [ #figure( caption: "Suddivisione oraria per ruolo (PB)", table( columns: 2, [*Ruolo*], [*Ore*], [Responsabile], [42], [Amministratore], [56], [Analista], [35], [Progettista], [35], [Programmatore], [168], [Verificatore], [98], [Totale], [434], ) ) ], [ #set align(bottom) #let data = ( ("Responsabile", 42), ("Amministratore", 56), ("Analista", 35), ("Progettista", 35), ("Programmatore", 168), ("Verificatore", 98), ) #figure({ canvas({ import draw: * chart.piechart(..piechart-config, data) })}, caption: "Suddivisione oraria per ruolo (PB)", kind: "chart", supplement: "Grafico" ) ] ) #pagebreak() = Pianificazione del lavoro == Introduzione La pianificazione ricopre un ruolo fondamentale nello sviluppo dell'intero progetto. Svolge il compito di stabilire quali obiettivi raggiungere in periodi di tempo determinati, organizzando le risorse in modo da rendere lo sviluppo efficace ed efficiente. Lo scopo principale deve essere pianificare le azioni da intraprendere nel periodo successivo, definendo tempistiche, modalità e obiettivi. == Metodologia di lavoro Scrum Il gruppo si è imposto una metodologia di lavoro *Agile* mediante l'applicazione del framework Scrum, determinando periodi di lavoro di durata fissa terminanti con un'analisi retrospettiva degli stessi. Tale approccio è definibile *adattivo*, in grado dunque di adattarsi ad eventuali modifiche in corso d'opera, in merito soprattutto a cambiamenti di specifiche e requisiti. L'intero sviluppo è dunque organizzato in iterazioni di lunghezza fissa, denominati in Scrum come *sprint*. L'analisi retrospettiva e il frequente contatto con il Proponente permettono di indirizzare lo sviluppo verso la realizzazione di un prodotto finale che si attenga quanto più possibile ai requisiti desiderati dall'azienda e alle sue aspettative, e una documentazione dettagliata e precisa che evolve e migliora insieme al prodotto. === Eventi dettati dal framework La corretta applicazione del framework comporta il rispetto di determinati impegni, individuabili nello svolgimento di precisi eventi organizzativi quali: - *Sprint planning*: evento decisionale da tenersi prima dell'avvio dello sprint successivo. In questo incontro vengono stabiliti gli obiettivi da raggiungere e le task necessarie da compiere entro la fine dello stesso; - *Sprint review*: al termine dello sprint si compie un'azione di revisione del progresso, valutando gli obiettivi che sono stati (o meno) raggiunti; - *Sprint retrospective*: al termine dello sprint si compie un'azione di retrospettiva, analizzando eventuali criticità incontrate e stabilendo i possibili miglioramenti o meccanismi di mitigazione. === Organizzazione per sprint Gli sprint sono periodi di sviluppo di durata fissa entro i quali si cerca di raggiungere obiettivi prefissati. Ciascuno sprint viene stabilito, in termini di scope e obiettivi, in un momento precedente all'avvio dello sprint stesso. Il gruppo _Error\_418_ adotta periodi di sprint di una settimana, ove l'intento è fissare obiettivi concretamente raggiungibili nell'arco di tempo stabilito. Festività o esigenze organizzative peculiari potrebbero indurre variazioni nella durata di singoli sprint. La pianificazione di uno sprint sarà così composta: - *Obiettivi prefissati*: gli obiettivi che si intende raggiungere entro il termine dello sprint; - *Preventivo costi*: preventivo dei costi dello sprint, calcolato in base alle figure che vi operano e alla loro quantità di ore di lavoro previste. Essenziale in questa organizzazione è l'analisi retrospettiva al termine di ogni sprint. Essa permette di valutare in modo critico eventuali mancanze, criticità o errori che possono in questo modo venir affrontati per trovare soluzioni che ne mitighino gli effetti. È inoltre utile per identificare buone prassi e strategie che hanno portato a risultati positivi, in modo da poterle replicare in futuro. La retrospettiva di uno sprint si articolerà in: - *Obiettivi raggiunti*: obiettivi fissati e concretamente raggiunti al termine dello sprint; - *Obiettivi mancati*: obiettivi non raggiunti al termine dello sprint; - *Problematiche insorte*: analisi delle criticità riscontrate durante lo sprint, in modo da aver chiare le motivazioni che le hanno causate; - *Risoluzioni attuate*: azioni compiute in risposta alle problematiche riscontrate durante lo sprint, in modo che in futuro si possano prevenire o mitigare; - *Panoramica dei costi effettivi* (consuntivo): al termine dello sprint sarà possibile verificare se i costi preventivati rispecchino i costi effettivi, in base alle ore svolte per ogni ruolo; - *Monitoraggio costi e ore*: tabelle che riportano le ore e il budget rimanenti per ogni ruolo e complessivamente. === Rotazione dei ruoli Il gruppo _Error\_418_ adotta una rotazione dei ruoli, in modo da garantire che ciascun membro del gruppo abbia la possibilità di svolgere ciascun ruolo almeno una volta durante lo sviluppo del progetto. Questo permette di: - aderire alle linee guida del regolamento del progetto didattico; - offrire una visione d'insieme del progetto a tutti i membri del gruppo; - garantire che ciascun membro del gruppo possa sviluppare competenze trasversali. I ruoli assegnati a ciascun membro del gruppo sono riportati in @preventivi e @consuntivi. La ripartizione delle ore per ciascun ruolo è riportata in @prospetto-orario-complessivo. #pagebreak() = Preventivi di periodo <preventivi> Il preventivo di ogni sprint esprime gli obiettivi e il relativo costo preventivato, secondo un'attività di pianificazione mirata al conseguimento efficace ed efficiente degli obiettivi di periodo. == Sprint 1 dal 06-11-2023 al 13-11-2023 === Obiettivi prefissati Gli obiettivi del primo sprint si concentrano sulla correzione e sul miglioramento dei documenti e della repository in seguito alla valutazione esposta dal Committente. Gli obiettivi dello sprint 1 sono: - riconfigurazione della repository; - revisione preventivo costi con aggiornamento della suddivisione delle ore; - implementazione di automazioni per la compilazione dei documenti; - implementazione di automazioni per il versionamento dei documenti; - stesura delle domande in merito al dominio tecnologico del capitolato; - contatto con l'azienda Proponente per comunicare l'esito della candidatura; - contatto con l'azienda Proponente per fissare un primo meeting di analisi. === Preventivo costi Nel primo sprint il gruppo svolge compiti correttivi e incentrati sul miglioramento dei documenti e dei processi. In quest'ottica, vede l'impiego principale delle figure: - *Responsabile*: al fine di coordinare le attività e contattare l'azienda Proponente; - *Amministratore*: al fine di gestire gli strumenti GitHub e Jira per la definizione delle automazioni per la compilazione e il versionamento dei documenti; - *Verificatore*: al fine di garantire che le modifiche effettuate rispecchino gli standard qualitativi desiderati e implementino effettivamente le mancanze individuate dalla valutazione; - *Analista*: al fine di redigere le principali domande da porre al Proponente in merito al dominio tecnologico da utilizzare. In questo primo periodo, l'assegnazione dei ruoli di Progettista e di Programmatore è ritenuta precoce. #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [0], [0], [0], [3], [3], [Carraro], [0], [4], [0], [0], [0], [0], [4], [Gardin], [0], [4], [0], [0], [0], [0], [4], [Nardo], [0], [0], [0], [0], [0], [3], [3], [Oseliero], [3], [0], [0], [0], [0], [0], [3], [Todesco], [0], [0], [3], [0], [0], [0], [3], [Zaccone], [0], [0], [3], [0], [0], [0], [3], [Totale ore], [3], [8], [6], [0], [0], [6], [23], [Costo\ ruolo], [€ 90], [€ 160], [€ 150], [€ 0], [€ 0], [€ 90], [€ 490], ), caption: "Prospetto del preventivo, sprint 1" ) #let data = ( ("Responsabile", 3), ("Amministratore", 8), ("Analista", 6), ("Progettista", 0), ("Programmatore", 0), ("Verificatore", 6), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo, preventivo sprint 1", kind: "chart", supplement: "Grafico" ) == Sprint 2 dal 13-11-2023 al 20-11-2023 === Obiettivi prefissati Gli obiettivi del secondo sprint si concentrano sull'individuazione degli Use Case del progetto, sul perfezionamento delle automazioni e sulla stesura iniziale delle Norme di Progetto. Gli obiettivi dello sprint 2 sono: - riconfigurazione della repository; - stesura della sezione _Introduzione_ del documento Norme di Progetto; - stesura della sezione _Processi di supporto_ del documento Norme di Progetto; - perfezionamento delle automazioni per la compilazione dei documenti; - implementazione delle automazioni per il versionamento dei documenti; - contatto con l'azienda Proponente per comunicare l'esito della candidatura; - meeting con l'azienda Proponente per riflettere sull'analisi dei requisiti e sulle tecnologie da usare; - inizio dell'individuazione e della stesura degli Use Case. === Preventivo costi Nel secondo sprint il gruppo svolge compiti correttivi incentrati sul miglioramento dei documenti e compiti orientati all'individuazione e alla stesura degli Use Case. In quest'ottica, vede l'impiego principale delle figure: - *Responsabile*: al fine di coordinare le attività e contattare l'azienda Proponente; - *Amministratore*: al fine di gestire gli strumenti GitHub e Jira per la definizione e il miglioramento delle automazioni per la compilazione e il versionamento dei documenti; - *Verificatore*: al fine di garantire che le modifiche effettuate rispecchino gli standard qualitativi desiderati e implementino effettivamente le mancanze individuate dalla valutazione; - *Analista*: al fine di individuare e sviluppare testualmente i principali Use Case in ottica del documento Analisi dei Requisiti. In questo periodo, l'assegnazione dei ruoli di Programmatore e Progettista è ritenuta precoce. #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [0], [0], [0], [3], [3], [Carraro], [0], [4], [0], [0], [0], [0], [4], [Gardin], [0], [4], [0], [0], [0], [0], [4], [Nardo], [0], [0], [3], [0], [0], [0], [3], [Oseliero], [3], [0], [0], [0], [0], [0], [3], [Todesco], [0], [0], [3], [0], [0], [0], [3], [Zaccone], [0], [0], [3], [0], [0], [0], [3], [Totale ore], [3], [8], [9], [0], [0], [3], [23], [Costo\ ruolo], [€ 90], [€ 160], [€ 225], [€ 0], [€ 0], [€ 45], [€ 520], ), caption: "Prospetto del preventivo, sprint 2" ) #let data = ( ("Responsabile", 3), ("Amministratore", 8), ("Analista", 9), ("Progettista", 0), ("Programmatore", 0), ("Verificatore", 3), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo, preventivo sprint 2", kind: "chart", supplement: "Grafico" ) == Sprint 3 dal 20-11-2023 al 27-11-2023 === Obiettivi prefissati Gli obiettivi del terzo sprint si concentrano sull'aggiornamento del documento Norme di Progetto, sul periodo di analisi dei requisiti (principalmente concentrata sui requisiti funzionali) e su un primo momento di esplorazione delle nuove tecnologie. Gli obiettivi dello sprint 3 sono: - proseguimento del processo di individuazione e stesura degli Use Case; - perfezionamento delle automazioni di versionamento documenti; - perfezionamento del template usato per i documenti; - aggiornamento del documento Norme di Progetto; - studio iniziale della libreria Three.js; - meeting con l'azienda Proponente per esporre ipotesi e Use Case individuati, richiedere chiarimenti ed avanzare opportune richieste; - contatto con l'azienda Proponente per fissare il prossimo meeting. === Preventivo costi Nel terzo sprint, il gruppo svolge delle attività principalmente focalizzate sull'analisi dei requisiti e sull'aggiornamento e perfezionamento dei documenti e delle automazioni. In quest'ottica, vede l'impiego principale delle figure: - *Responsabile*: al fine di coordinare le attività e contattare l'azienda Proponente; - *Amministratore*: al fine di: - gestire gli strumenti GitHub e Jira per la definizione delle automazioni per la compilazione e il versionamento dei documenti; - aggiornare il documento Piano di Progetto. - *Verificatore*: al fine di: - verificare la correttezza delle modifiche ai documenti; - effettuare un controllo sulla validità e formulazione degli Use Case individuati. - *Analista*: al fine di individuare e formulare gli Use Case correlati ai requisiti funzionali; - *Progettista*: al fine di condurre uno studio iniziale sulla libreria Three.js. In questo periodo, l'assegnazione del ruolo di Programmatore è ritenuta precoce. #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [3], [0], [0], [0], [0], [0], [3], [Carraro], [0], [0], [4], [0], [0], [0], [4], [Gardin], [0], [0], [0], [0], [0], [3], [3], [Nardo], [0], [0], [0], [3], [0], [0], [3], [Oseliero], [0], [0], [4], [0], [0], [0], [4], [Todesco], [0], [3], [0], [0], [0], [0], [3], [Zaccone], [0], [3], [0], [0], [0], [0], [3], [Totale ore], [3], [6], [8], [3], [0], [3], [23], [Costo\ ruolo], [€ 90], [€ 120], [€ 200], [€ 75], [€ 0], [€ 45], [€ 530], ), caption: "Prospetto del preventivo, sprint 3" ) #let data = ( ("Responsabile", 3), ("Amministratore", 6), ("Analista", 8), ("Progettista", 3), ("Programmatore", 0), ("Verificatore", 3), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo, preventivo sprint 3", kind: "chart", supplement: "Grafico" ) == Sprint 4 dal 27-11-2023 al 04-12-2023 === Obiettivi prefissati Gli obiettivi del quarto sprint si concentrano sull'aggiornamento e perfezionamento dei documenti redatti negli scorsi sprint, sulla finalizzazione di una prima versione del documento Analisi dei Requisiti e sull'esplorazione delle nuove tecnologie. Gli obiettivi dello sprint 4 sono: - perfezionamento della stesura degli Use Case individuati finora; - redazione di una prima versione dell'Analisi dei Requisiti; - scelta di una data per un eventuale primo meeting con il Professor Cardin per ottenere un feedback sull'Analisi dei Requisiti; - proseguimento della redazione e aggiornamento del documento Norme di Progetto; - proseguimento periodo di studio di Three.js, finalizzato a: - creazione di alcuni scaffali nell'ambiente tridimensionale; - implementazione sistema di _drag and drop_; - parametrizzazione degli elementi presenti nell'applicazione. === Preventivo costi Nel quarto sprint il gruppo svolge compiti correttivi incentrati sul miglioramento dei documenti, Analisi dei Requisiti e studio delle nuove tecnologie. In quest'ottica, vede l'impiego principale delle figure: - *Responsabile*: al fine di coordinare le attività e contattare l'azienda Proponente; - *Amministratore*: al fine di: - gestire gli strumenti GitHub e Jira per la definizione delle automazioni per la compilazione e il versionamento dei documenti; - aggiornare il documento Piano di Progetto. - *Analista*: al fine di perfezionare la stesura degli Use Case individuati e redigere una prima versione del documento Analisi dei Requisiti; - *Progettista*: al fine di condurre uno studio esplorativo sulla libreria Three.js; - *Programmatore*: al fine di esplorare in modo pratico le tecnologie relative ai PoC; - *Verificatore*: al fine di verificare la correttezza delle modifiche ai documenti e di effettuare un controllo sulla validità degli Use Case individuati nel documento Analisi dei Requisiti. #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [3], [0], [0], [0], [0], [0], [3], [Carraro], [0], [0], [3], [0], [1], [0], [4], [Gardin], [0], [0], [0], [0], [0], [3], [3], [Nardo], [0], [0], [0], [1], [2], [0], [3], [Oseliero], [0], [0], [4], [0], [0], [0], [4], [Todesco], [0], [3], [0], [0], [0], [0], [3], [Zaccone], [0], [3], [0], [0], [0], [0], [3], [Totale ore], [3], [6], [7], [1], [3], [3], [23], [Costo\ ruolo], [€ 90], [€ 120], [€ 175], [€ 25], [€ 45], [€ 45], [€ 500], ), caption: "Prospetto del preventivo, sprint 4" ) #let data = ( ("Responsabile", 3), ("Amministratore", 6), ("Analista", 7), ("Progettista", 1), ("Programmatore", 3), ("Verificatore", 3), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo, preventivo sprint 4", kind: "chart", supplement: "Grafico" ) == Sprint 5 dal 04-12-2023 al 11-12-2023 === Obiettivi prefissati Gli obiettivi del quinto sprint si concentrano sull'aggiornamento e perfezionamento dei documenti redatti negli scorsi sprint, sulla finalizzazione di una prima versione del documento Analisi dei Requisiti e sullo sviluppo dei primi PoC. Gli obiettivi dello sprint 5 sono: - perfezionamento del sistema di _drag and drop_ nel PoC; - creazione degli scaffali nel PoC; - creazione ambiente Docker; - svolgere meeting con il Professor Cardin in merito all'Analisi dei Requisiti; - perfezionare e aggiornare il documento Norme di Progetto; - aggiornamento del documento Analisi dei Requisiti, introducendo i requisiti non funzionali; - informarsi sul documento Piano di Qualifica; - aggiornare vecchi documenti con il nuovo template; - migliorare affidabilità GitHub Actions; - redigere il Glossario. === Preventivo costi Nel quinto sprint il gruppo svolge compiti correttivi incentrati sul miglioramento dei documenti, Analisi dei Requisiti e studio delle nuove tecnologie. In quest'ottica, vede l'impiego principale delle figure: - *Responsabile*: al fine di coordinare le attività e contattare l'azienda Proponente; - *Amministratore*: al fine di gestire gli strumenti GitHub e Jira; - *Analista*: al fine di redigere il documento Analisi dei Requisiti; - *Progettista*: al fine di continuare lo studio sulla libreria Three.js; - *Programmatore*: al fine di sviluppare i PoC relativi allo studio della libreria; - *Verificatore*: al fine di: - verificare la correttezza delle modifiche ai documenti; - effettuare un controllo sulla validità e formulazione degli Use Case individuati e del documento Analisi dei Requisiti. #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [4], [0], [0], [0], [4], [Carraro], [3], [0], [0], [0], [2], [0], [5], [Gardin], [0], [0], [4], [0], [0], [0], [4], [Nardo], [0], [3], [0], [0], [2], [0], [5], [Oseliero], [0], [0], [0], [2], [2], [0], [4], [Todesco], [0], [0], [0], [0], [0], [3], [3], [Zaccone], [0], [0], [0], [2], [2], [0], [4], [Totale ore], [3], [3], [8], [4], [8], [3], [29], [Costo\ ruolo], [€ 90], [€ 60], [€ 200], [€ 100], [€ 120], [€ 45], [€ 615], ), caption: "Prospetto del preventivo, sprint 5" ) #let data = ( ("Responsabile", 3), ("Amministratore", 3), ("Analista", 8), ("Progettista", 4), ("Programmatore", 8), ("Verificatore", 3), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo, preventivo sprint 5", kind: "chart", supplement: "Grafico" ) == Sprint 6 dal 11-12-2023 al 18-12-2023 === Obiettivi prefissati Gli obiettivi del sesto sprint si focalizzano sul miglioramento dei PoC e dei diversi documenti. Nel dettaglio: - avanzare con la redazione del PoC "A" integrando il funzionamento dei bin; - approfondire e migliorare l'utilizzo di Docker nel PoC corrispondente; - migliorare le GitHub Actions risolvendo eventuali problemi o aggiungendo funzionalità; - proseguire con il lavoro sul documento Norme di Progetto; - redigere introduzione del documento Piano di Qualifica; - adeguare l'Analisi dei Requisiti in funzione di quanto emerso durante lo scorso meeting con il Professor Cardin; - aggiungere al documento Analisi dei Requisiti la tabella che correli gli Use Case ai requisiti. === Preventivo costi Nel sesto sprint il gruppo svolge compiti correttivi incentrati sul miglioramento dei documenti Analisi dei Requisiti e Norme di Progetto. Il gruppo continua a produrre e migliorare PoC e inizia a scrivere il documento Piano di Qualifica. In quest'ottica vede l'impiego principale delle figure: - *Responsabile*: al fine di coordinare le attività e contattare l'azienda Proponente; - *Amministratore*: al fine di gestire gli strumenti GitHub e Jira, redigere i verbali e aggiornare il documento Piano di Progetto; - *Analista*: al fine di redigere il documento Analisi dei Requisiti con relativi diagrammi UML; - *Progettista*: al fine di progettare i PoC; - *Programmatore*: al fine di sviluppare i PoC; - *Verificatore*: al fine di verificare la correttezza delle modifiche ai documenti assicurandosi che siano coerenti con le Norme di Progetto. #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [4], [0], [0], [0], [4], [Carraro], [3], [0], [0], [0], [0], [0], [3], [Gardin], [0], [0], [4], [0], [0], [0], [4], [Nardo], [0], [3], [0], [0], [0], [0], [3], [Oseliero], [0], [0], [0], [1], [3], [0], [4], [Todesco], [0], [0], [0], [0], [0], [3], [3], [Zaccone], [0], [0], [0], [1], [3], [0], [4], [Totale ore], [3], [3], [8], [2], [6], [3], [25], [Costo\ ruolo], [€ 90], [€ 60], [€ 200], [€ 50], [€ 90], [€ 45], [€ 535], ), caption: "Prospetto del preventivo, sprint 6" ) #let data = ( ("Responsabile", 3), ("Amministratore", 3), ("Analista", 8), ("Progettista", 2), ("Programmatore", 6), ("Verificatore", 3), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo, preventivo sprint 6", kind: "chart", supplement: "Grafico" ) == Sprint 7 dal 18-12-2023 al 25-12-2023 === Obiettivi prefissati Gli obiettivi del settimo sprint si focalizzano sul completamento del PoC A, terminare l'analisi dei requisiti e in generale sull'avanzamento dei documenti e miglioramento delle automazioni. Nel dettaglio gli obiettivi posti sono: - creazione di un PoC per il front-end e realizzazione di un PoC definitivo comprendente tutto il lavoro svolto finora; - espansione del Piano di Qualifica con l'individuazione delle metriche da utilizzare; - aggiornamento delle Norme di Progetto; - completamento del documento Analisi dei Requisiti con: - implementazione del tracciamento requisito-fonte; - revisione generale del documento per verificare la presenza e correttezza di tutti gli Use Case e requisiti necessari. - miglioramento delle GitHub Actions risolvendo eventuali problemi o aggiungendo funzionalità; - implementazione dell'automazione che evidenzia i termini presenti nel glossario all'interno dei documenti. === Preventivo costi Nel settimo sprint i compiti del gruppo sono incentrati sulla realizzazione del PoC finale e sul proseguimento e miglioramento di tutti i documenti necessari alla Requirements and Technology Baseline. Di conseguenza saranno essenziali le figure di: - *Responsabile*: al fine di coordinare le attività e proseguire la redazione delle Norme di Progetto; - *Amministratore*: al fine di: - redigere i verbali; - aggiornare il documento Piano di Progetto; - gestire GitHub e Jira; - migliorare le GitHub Actions risolvendo gli errori legati al versionamento dei file e all'aggiornamento dei changelog. - *Analista*: al fine di migliorare il documento Analisi dei Requisiti e aggiungere il tracciamento requisito-fonte; - *Progettista*: al fine di studiare e confrontare le tecnologie per il front-end individuate; - *Programmatore*: al fine di realizzare un PoC per il front-end e un PoC finale; - *Verificatore*: al fine di: - verificare la correttezza del lavoro prodotto e la sua coerenza con le Norme di Progetto; - individuare le metriche da inserire nel Piano di Qualifica. #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [4], [0], [0], [0], [0], [4], [Carraro], [0], [0], [0], [0], [3], [0], [3], [Gardin], [0], [0], [0], [3], [0], [0], [3], [Nardo], [3], [0], [0], [0], [0], [0], [3], [Oseliero], [0], [0], [0], [0], [2], [2], [4], [Todesco], [0], [0], [0], [3], [0], [0], [3], [Zaccone], [0], [0], [3], [0], [0], [0], [3], [Totale ore], [3], [4], [3], [6], [5], [2], [23], [Costo\ ruolo], [€ 90], [€ 80], [€ 75], [€ 150], [€ 75], [€ 30], [€ 500], ), caption: "Prospetto del preventivo, sprint 7" ) #let data = ( ("Responsabile", 3), ("Amministratore", 4), ("Analista", 3), ("Progettista", 6), ("Programmatore", 5), ("Verificatore", 2), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo, preventivo sprint 7", kind: "chart", supplement: "Grafico" ) == Sprint 8 dal 25-12-2023 al 01-01-2024 === Obiettivi prefissati <obiettivi8> Gli obiettivi dell'ottavo sprint si incentrano sul completamento delle attività rimaste sospese nel settimo sprint e sull'avanzamento del documento Norme di Progetto, oltre che sul miglioramento di alcuni aspetti di attività già concluse. Gli obiettivi prefissati per questo sprint sono: - miglioramento del Glossario: - rendere _case insensitive_ l'individuazione dei termini; - implementare la gestione di plurali e acronimi. - proseguimento del documento Analisi dei Requisiti con: - implementazione tracciamento requisito-fonte; - miglioramento della resa grafica dei diagrammi UML tramite la loro conversione in SVG. - proseguimento del documento Norme di Progetto, recuperando i capitoli non scritti nello sprint precedente e espandendone altri; - perfezionamento del PoC finale; - miglioramento delle GitHub Actions risolvendo eventuali problemi o aggiungendo funzionalità; - studio e confronto delle tecnologie riguardanti le API (Next.js e Express.js); - realizzazione di un sito web per la documentazione; - realizzazione di una dashboard per monitorare le metriche definite nel Piano di Qualifica. === Preventivo costi Gli obiettivi dell'ottavo sprint riguardano tutti gli aspetti del progetto, di conseguenza saranno necessari tutti i ruoli presenti nel gruppo: - *Responsabile*: al fine di coordinare le attività e proseguire la redazione delle Norme di Progetto; - *Amministratore*: al fine di: - redigere i verbali; - aggiornare il documento Piano di Progetto; - gestire GitHub e Jira; - migliorare le GitHub Actions individuando e rimuovendo bug; - migliorare il Glossario secondo quanto descritto nel paragrafo di pianificazione di questo sprint. - *Analista*: al fine di: - aggiungere il tracciamento requisito-fonte nel documento Analisi dei Requisiti; - convertire i diagrammi UML in SVG. - *Progettista*: al fine di studiare e confrontare le tecnologie per l'implementazione delle API; - *Programmatore*: al fine di proseguire con l'implementazione del PoC finale; - *Verificatore*: al fine di: - verificare la correttezza del lavoro prodotto e la sua coerenza con le Norme di Progetto; - realizzare una dashboard per il monitoraggio delle metriche. #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [3], [0], [0], [0], [0], [3], [Carraro], [0], [0], [0], [0], [3], [0], [3], [Gardin], [0], [0], [0], [3], [0], [0], [3], [Nardo], [4], [0], [0], [0], [0], [0], [4], [Oseliero], [0], [0], [0], [0], [0], [4], [4], [Todesco], [0], [0], [0], [3], [0], [0], [3], [Zaccone], [0], [0], [3], [0], [0], [0], [3], [Totale ore], [4], [3], [3], [6], [3], [4], [23], [Costo\ ruolo], [€ 120], [€ 60], [€ 75], [€ 150], [€ 45], [€ 60], [€ 510], ), caption: "Prospetto del preventivo, sprint 8" ) #let data = ( ("Responsabile", 4), ("Amministratore", 3), ("Analista", 3), ("Progettista", 6), ("Programmatore", 3), ("Verificatore", 4), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo, preventivo sprint 8", kind: "chart", supplement: "Grafico" ) == Sprint 9 dal 01-01-2024 al 08-01-2024 === Obiettivi prefissati <obiettivi9> Gli obiettivi dell'ottavo sprint si incentrano sul completamento delle attività rimaste sospese nell'ottavo sprint, sulla revisione dei documenti e del PoC in vista della valutazione RTB. Gli obiettivi prefissati per questo sprint sono: - estensione e revisione del documento Norme di Progetto; - correzione degli errori riscontrati in alcuni UC nel documento Analisi dei Requisiti, compreso l'aggiornamento dei diagrammi UML associati; - realizzazione di una dashboard per monitorare le metriche definite nel Piano di Qualifica; - revisione dei documenti prodotti finora; - risoluzione dei problemi legati all'automazione per il versionamento dei documenti; - ripresa dei contatti con il Proponente tramite l'invio di una comunicazione di aggiornamento corredata da un video demo del PoC. === Preventivo costi Gli obiettivi del nono sprint riguardano i seguenti ruoli: - *Responsabile*: al fine di: - coordinare le attività e proseguire la redazione delle Norme di Progetto; - contattare il Proponente fornendo aggiornamenti sull'avanzamento dei lavori. - *Amministratore*: al fine di: - redigere i verbali; - aggiornare il documento Piano di Progetto; - gestire GitHub e Jira; - migliorare le GitHub Actions individuando e rimuovendo bug; - realizzare una dashboard per il monitoraggio delle metriche. - *Analista*: al fine di correggere gli errori riscontrati in alcuni UC nel documento Analisi dei Requisiti; - *Verificatore*: al fine di: - revisionare i documenti prodotti nel corso degli sprint precedenti; - verificare la correttezza del lavoro prodotto e la sua coerenza con le Norme di Progetto. #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [5], [0], [0], [0], [0], [5], [Carraro], [0], [0], [0], [0], [0], [4], [4], [Gardin], [0], [5], [0], [0], [0], [0], [5], [Nardo], [0], [0], [0], [0], [0], [4], [4], [Oseliero], [0], [0], [5], [0], [0], [0], [5], [Todesco], [0], [0], [0], [0], [0], [4], [4], [Zaccone], [4], [0], [0], [0], [0], [0], [4], [Totale ore], [4], [10], [5], [0], [0], [12], [31], [Costo\ ruolo], [€ 120], [€ 200], [€ 125], [€ 0], [€ 0], [€ 180], [€ 625], ), caption: "Prospetto del preventivo, sprint 9" ) #let data = ( ("Responsabile", 4), ("Amministratore", 10), ("Analista", 5), ("Progettista", 0), ("Programmatore", 0), ("Verificatore", 12), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo, preventivo sprint 9", kind: "chart", supplement: "Grafico" ) == Sprint 10 dal 08-01-2024 al 14-01-2024 === Obiettivi prefissati Gli obiettivi del decimo sprint vertono sulla revisione dei documenti in preparazione per il colloquio RTB. Gli obiettivi prefissati per questo sprint sono: - verificare la correttezza dei documenti redatti finora; - identificare e correggere le cause del problema prestazionale del PoC; - introdurre la compilazione automatica del documento a seguito dell'aggiornamento manuale di un changelog; - ampliare la dashboard di monitoraggio con nuove visualizzazioni; - preparare la presentazione a supporto della valutazione RTB in Google Slides. La durata dello sprint è inferiore di 1 giorno rispetto alla norma. === Preventivo costi L'attività prevalente è la revisione documentale. I ruoli attivi durante questo sprint sono: - *Responsabile*: al fine di: - coordinare le attività; - redigere la presentazione a supporto della valutazione RTB. - *Amministratore*: al fine di: - redigere i verbali; - aggiornare il documento Piano di Progetto; - aggiornare le visualizzazioni della dashboard di monitoraggio; - gestire GitHub e Jira. - *Analista*: al fine di: - ultimare la revisione del documento Analisi dei Requisiti. - *Programmatore*: al fine di: - identificare e correggere le cause del problema prestazionale del PoC. - *Verificatore*: al fine di: - verificare la correttezza del lavoro prodotto e la sua coerenza con le Norme di Progetto; - ricontrollare i documenti prodotti e correggere eventuali errori riscontrati. #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [0], [0], [0], [3], [3], [Carraro], [0], [0], [0], [0], [0], [2], [2], [Gardin], [0], [2], [0], [0], [0], [0], [2], [Nardo], [0], [0], [0], [0], [2], [0], [2], [Oseliero], [0], [0], [2], [0], [0], [0], [2], [Todesco], [0], [0], [0], [0], [2], [0], [2], [Zaccone], [2], [0], [0], [0], [0], [3], [5], [Totale ore], [2], [2], [2], [0], [4], [8], [18], [Costo\ ruolo], [€ 60], [€ 40], [€ 50], [€ 0], [€ 60], [€ 120], [€ 330], ), caption: "Prospetto del preventivo, sprint 10" ) #let data = ( ("Responsabile", 2), ("Amministratore", 2), ("Analista", 2), ("Progettista", 0), ("Programmatore", 4), ("Verificatore", 8), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo, preventivo sprint 10", kind: "chart", supplement: "Grafico" ) == Sprint 11 dal 14-01-2024 al 21-01-2024 === Obiettivi prefissati Gli obiettivi dell'undicesimo sprint si incentrano sulla preparazione per il colloquio RTB oltre che sulla revisione di alcuni aspetti di attività già concluse. Gli obiettivi prefissati per questo sprint sono: - aggiornare il Piano di Qualifica con nuove metriche individuate riguardanti: - budget utilizzato; - ore rimanenti. - rimuovere Express dal PoC a seguito del feedback del Professor Cardin; - registrazione di un video dimostrazione del PoC destinato al proponente; - creazione di un collegamento tra Jira e Grafana per il cruscotto di controllo della qualità; - ultimare il documento Analisi dei Requisiti con alcune modifiche minori agli Use Cases; - verificare la correttezza dei documenti redatti finora; - preparare la candidatura per il colloquio RTB: - Redigere nuova lettera di presentazione con aggiornamento di preventivo; - Continuare la revisione dei documenti. === Preventivo costi Sono state assegnate ore al ruolo di Verificatore e Analista a scapito di quello di Programmatore in quanto il PoC risulta ormai ultimato: - *Responsabile*: al fine di coordinare le attività. - *Amministratore*: al fine di: - redigere i verbali; - aggiornare il documento Piano di Progetto; - gestire GitHub e Jira. - *Analista*: al fine di: - ultimare alcune modifiche al documento Analisi dei Requisiti; - ricontrollare interamente il documento di Analisi dei Requisiti. - *Progettista*: al fine di mettere per iscritto le motivazioni che hanno portato alla scelta delle tecnologie utilizzate nel PoC. - *Verificatore*: al fine di: - verificare la correttezza del lavoro prodotto e la sua coerenza con le Norme di Progetto; - ricontrollare i documenti prodotti e correggere eventuali errori riscontrati; - inserire nel Piano di Qualifica alcune metriche nuove. #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [2], [0], [0], [0], [2], [Carraro], [0], [0], [0], [0], [0], [2], [2], [Gardin], [0], [0], [0], [0], [0], [2], [2], [Nardo], [3], [0], [0], [0], [0], [0], [3], [Oseliero], [0], [0], [1], [0], [0], [0], [1], [Todesco], [0], [3], [0], [0], [0], [0], [3], [Zaccone], [0], [0], [0], [0], [0], [2], [2], [Totale ore], [3], [3], [3], [0], [0], [6], [15], [Costo ruolo], [€ 90], [€ 60], [€ 75], [€ 0], [€ 0], [€ 90], [€ 315], ), caption: "Prospetto del preventivo, sprint 11" ) #let data = ( ("Responsabile", 3), ("Amministratore", 3), ("Analista", 3), ("Progettista", 0), ("Programmatore", 0), ("Verificatore", 6), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo, preventivo sprint 11", kind: "chart", supplement: "Grafico" ) == Sprint 12 dal 21-01-2024 al 28-01-2024 === Obiettivi prefissati Gli obiettivi del dodicesimo sprint riguardano la partecipazione al colloquio RTB con il Professor Cardin, in data 25/01/2024 alle ore 8:40. In questo sprint inizia la sessione d'esame invernale. Gli obiettivi prefissati per questo sprint sono: - estensione dei termini di Glossario; - aggiunta di grafici significativi al Piano di Progetto, come ad esempio la suddivisione oraria per ruolo, mediante il pacchetto `plotst` di Typst; - correzione minore della tabella che riporta il computo dei requisiti totali nel documento di Analisi dei Requisiti; - ripasso generale individuale e collettivo prima del colloquio RTB. === Preventivo costi Dato lo scope ridotto del lavoro, questo sprint impiega un numero di ore inferiore rispetto agli sprint precedenti. I ruoli attivi durante questo sprint sono: - *Responsabile*: al fine di coordinare le attività. - *Amministratore*: al fine di: - redigere i verbali; - aggiornare il documento Piano di Progetto. - *Progettista*: al fine di estendere i termini del Glossario. - *Verificatore*: al fine di: - verificare la correttezza del lavoro prodotto e la sua coerenza con le Norme di Progetto; - ricontrollare i documenti prodotti e correggere eventuali errori riscontrati. #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [0], [1], [0], [0], [1], [Carraro], [0], [0], [0], [1], [0], [0], [1], [Gardin], [0], [0], [0], [1], [0], [0], [1], [Nardo], [1], [0], [0], [0], [0], [0], [1], [Oseliero], [0], [0], [0], [0], [0], [1], [1], [Todesco], [0], [1], [0], [0], [0], [0], [1], [Zaccone], [0], [0], [0], [0], [0], [1], [1], [Totale ore], [1], [1], [0], [3], [0], [2], [7], [Costo\ ruolo], [€ 30], [€ 20], [€ 0], [€ 75], [€ 0], [€ 30], [€ 155], ), caption: "Prospetto del preventivo, sprint 12" ) #let data = ( ("Responsabile", 1), ("Amministratore", 1), ("Analista", 0), ("Progettista", 3), ("Programmatore", 0), ("Verificatore", 2), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo, preventivo sprint 12", kind: "chart", supplement: "Grafico" ) == Sprint 13 dal 28-01-2024 al 04-02-2024 === Obiettivi prefissati Nessuno che esuli dalla normale amministrazione di progetto. Il gruppo attende la valutazione del colloquio RTB e si prepara per la sessione d'esame. === Preventivo costi Questo sprint impiega: - *Responsabile*: al fine di: - coordinare le attività; - organizzare il lavoro in reazione al feedback, se ricevuto. - *Amministratore*: al fine di: - redigere i verbali; - aggiornare il documento Piano di Progetto. #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [0], [0], [0], [0], [0], [Carraro], [0], [0], [0], [0], [0], [0], [0], [Gardin], [2], [0], [0], [0], [0], [0], [2], [Nardo], [0], [0], [0], [0], [0], [0], [0], [Oseliero], [0], [1], [0], [0], [0], [0], [1], [Todesco], [0], [0], [0], [0], [0], [0], [0], [Zaccone], [0], [0], [0], [0], [0], [0], [0], [Totale ore], [2], [1], [0], [0], [0], [0], [3], [Costo\ ruolo], [€ 60], [€ 20], [€ 0], [€ 0], [€ 0], [€ 0], [€ 80], ), caption: "Prospetto del preventivo, sprint 13" ) #let data = ( ("Responsabile", 2), ("Amministratore", 1), ("Analista", 0), ("Progettista", 0), ("Programmatore", 0), ("Verificatore", 0), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo, preventivo sprint 13", kind: "chart", supplement: "Grafico" ) == Sprint 14 dal 04-02-2024 al 11-02-2024 === Obiettivi prefissati Il feedback ricevuto dopo il colloquio RTB con il Professor Cardin ha evidenziato la necessità di una profonda revisione del documento di Analisi dei Requisiti, che pertanto è il focus principale di questo sprint. Gli obiettivi prefissati per questo sprint sono: - revisione, correzione ed estensione del documento Analisi dei Requisiti secondo il feedback ricevuto; - preparazione in vista del colloquio RTB con il Professor Vardanega (data da definire); - inclusione nella dashboard di monitoraggio delle metriche individuate nel corso dello sprint precedente; - estensione dei termini di Glossario; - invio aggiornamento sullo stato del progetto al Proponente. === Preventivo costi Questo sprint impiega: - *Responsabile*: al fine di: - coordinare le attività; - contattare il Proponente fornendo aggiornamenti sull'avanzamento dei lavori. - *Amministratore*: al fine di: - redigere i verbali; - aggiornare il documento Piano di Progetto; - aggiornare la dashboard di monitoraggio. - *Analista*: al fine di implementare le correzioni e le estensioni al documento Analisi dei Requisiti; - *Progettista*: al fine di estendere i termini del Glossario. - *Verificatore*: al fine di: - verificare la correttezza del lavoro prodotto e la sua coerenza con le Norme di Progetto; - ricontrollare i documenti prodotti e correggere eventuali errori riscontrati. #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [3], [0], [0], [0], [3], [Carraro], [0], [1], [1], [0], [0], [2], [4], [Gardin], [3], [0], [2], [0], [0], [0], [5], [Nardo], [0], [0], [2], [0], [0], [3], [5], [Oseliero], [0], [2], [0], [0], [0], [2], [4], [Todesco], [0], [0], [0], [1], [0], [3], [4], [Zaccone], [0], [0], [0], [1], [0], [3], [4], [Totale ore], [3], [3], [8], [2], [0], [13], [29], [Costo\ ruolo], [€ 90], [€ 60], [€ 200], [€ 50], [€ 0], [€ 195], [€ 595], ), caption: "Prospetto del preventivo, sprint 14" ) #let data = ( ("Responsabile", 3), ("Amministratore", 3), ("Analista", 8), ("Progettista", 2), ("Programmatore", 0), ("Verificatore", 13), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo, preventivo sprint 14", kind: "chart", supplement: "Grafico" ) == Sprint 15 dal 11-02-2024 al 18-02-2024 === Obiettivi prefissati Questo sprint si occupa della preparazione per il colloquio RTB con il #vardanega e avvia le attività di progettazione del prodotto software. Gli obiettivi prefissati per questo sprint sono: - definizione del diagramma ER del database da implementare; - studio preliminare degli elementi architetturali del prodotto; - identificazione degli strumenti di appoggio per l'implementazione di una pipeline di CI/CD; - configurazione della repository e dei suddetti strumenti; - miglioramento della struttura informativa del documento #adr, in particolare per quanto riguarda il tracciamento tra casi d'uso e requisiti; - aggiornamento delle GitHub Actions recentemente deprecate (`actions/upload-artifact`, `actions/download-artifact`, `actions/setup-python`); - prenotazione del colloquio RTB con il #vardanega, nella seconda metà della settimana. === Preventivo costi Questo sprint impiega: - *Responsabile*: al fine di: - coordinare le attività; - candidare il gruppo al colloquio RTB; - contattare il Proponente fornendo aggiornamenti sull'avanzamento dei lavori. - *Amministratore*: al fine di: - redigere i verbali; - aggiornare il documento #pdp; - identificare gli strumenti di appoggio per l'implementazione di una pipeline di CI/CD; - configurare la repository e i suddetti strumenti. - *Analista*: al fine di: - migliorare il tracciamento tra casi d'uso e requisiti nel documento #adr. - *Progettista*: al fine di: - definire il diagramma ER del database; - studiare gli elementi architetturali del prodotto. - *Programmatore*: al fine di: - implementare uno scheletro dell'applicazione, simile al PoC per struttura ma privo dell'ambiente fornito da Three.js, con Docker Compose; - realizzare un primo prototipo del database; - aggiornare le GitHub Actions che fanno uso di dipendenze recentemente deprecate (`actions/upload-artifact`, `actions/download-artifact`, `actions/setup-python`). - *Verificatore*: al fine di verificare la correttezza del lavoro prodotto e la sua coerenza con le #ndp. #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [0], [2], [3], [0], [5], [Carraro], [0], [0], [0], [0], [0], [3], [3], [Gardin], [0], [0], [0], [0], [3], [0], [3], [Nardo], [0], [2], [3], [0], [0], [0], [5], [Oseliero], [0], [2], [0], [2], [0], [0], [4], [Todesco], [3], [0], [0], [0], [0], [0], [3], [Zaccone], [0], [0], [0], [0], [0], [4], [4], [Totale ore], [3], [4], [3], [4], [6], [7], [27], [Costo ruolo], [90], [80], [75], [100], [90], [105], [540], ), caption: "Prospetto del preventivo, sprint 15" ) #let data = ( ("Responsabile", 3), ("Amministratore", 4), ("Analista", 3), ("Progettista", 4), ("Programmatore", 6), ("Verificatore", 7), ) #figure({ roles-legend canvas({ import draw: * chart.piechart(..piechart-config, data)} )}, caption: "Suddivisione oraria per ruolo, preventivo sprint 15", kind: "chart", supplement: "Grafico" ) #pagebreak() = Consuntivi di periodo <consuntivi> Il consuntivo di ogni sprint permette di avere una valutazione critica dell'avanzamento dello sviluppo, valutando in modo oggettivo i punti positivi e negativi dello sprint terminato. Questa fase di retrospettiva è essenziale al fine di individuare possibili miglioramenti e di analizzare se la pianificazione ideata all'inizio dello sprint sia stata concreta ed efficace. == Sprint 1 dal 06-11-2023 al 13-11-2023 === Obiettivi raggiunti - Revisione preventivo costi con aggiornamento della suddivisione delle ore e conseguente riduzione del costo totale; - Implementazione di automazioni per la compilazione dei documenti; - Stesura delle domande in merito al dominio tecnologico del capitolato. === Obiettivi mancati - Riconfigurazione della repository; - Implementazione di automazioni per il versionamento dei documenti; - Contatto con l'azienda Proponente per comunicare l'esito della candidatura; - Contatto con l'azienda Proponente per fissare un primo meeting di analisi. === Problematiche A causa di una sottostima del carico di lavoro per l'implementazione delle automazioni tramite GitHub Actions, alcuni obiettivi sono stati mancati, creando un effetto a catena che ha temporaneamente bloccato il caricamento di documenti nella repository. Un altro problema riguarda la comunicazione con l'azienda Proponente: sfortunatamente, la mail inviata non ha ricevuto riscontro in tempo, impedendo di procedere ulteriormente con l'analisi dei requisiti e la programmazione di un meeting con l'azienda. === Risoluzioni attuate Le automazioni riguardanti il versionamento verranno concluse nello sprint successivo. La problematica in merito al contatto con l'azienda vedrà l'intraprendersi di un'azione di sollecito con una seconda mail, e successivamente la richiesta di stabilire un nuovo canale di comunicazione. === Panoramica dei costi effettivi #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [0], [0], [0], [2 (-1)], [2 (-1)], [Carraro], [0], [4], [0], [0], [0], [0], [4], [Gardin], [0], [4], [0], [0], [0], [0], [4], [Nardo], [0], [0], [0], [0], [0], [2 (-1)], [2 (-1)], [Oseliero], [2 (-1)], [4 (+4)], [0], [0], [0], [0], [6 (+3)], [Todesco], [0], [0], [2 (-1)], [0], [0], [0], [2 (-1)], [Zaccone], [0], [0], [2 (-1)], [0], [0], [0], [2 (-1)], [Totale ore], [2 (-1)], [12 (+4)], [4 (-2)], [0], [0], [4 (-2)], [22 (-1)], [Costo\ ruolo], [€ 60 (-30)], [€ 240 (+80)], [€ 100 (-50)], [€ 0], [€ 0], [€ 60 (-30)], [€ 460 (-30)], ), caption: "Prospetto del consuntivo, sprint 1" ) #let data = ( ("Responsabile", 3, 2), ("Amministratore", 8, 12), ("Analista", 6, 4), ("Progettista", 0, 0), ("Programmatore", 0, 0), ("Verificatore", 6, 4), ) #let x-coordinates = compute-labels-x-coordinate(data, role-chart-size) #let y-coordinates = compute-labels-y-coordinate(data, role-chart-size) #figure({ import draw: * canvas({ chart.barchart(..barchart-config, data) let i = 0 while(i < data.len()) { content( (x-coordinates.at(i).at(0), y-coordinates.at(i).at(0)), [#data.at(i).at(1)], ..barchart-label-config ) content( (x-coordinates.at(i).at(1), y-coordinates.at(i).at(1)), [#data.at(i).at(2)], ..barchart-label-config ) i += 1 } })}, caption: "Suddivisione oraria per ruolo, consuntivo sprint 1", kind: "chart", supplement: "Grafico" ) A causa dei rallentamenti incontrati, alcuni ruoli hanno visto un monte ore effettivo inferiore a quanto preventivato: - Responsabile: il blocco temporaneo della repository e la mancata risposta dell'azienda non hanno permesso la produzione di documenti, limitando così il lavoro del Responsabile; - Analista: la mancata risposta da parte dell'azienda ha impedito agli analisti di iniziare l'analisi dei requisiti, limitando dunque il lavoro alla stesura di domande in merito al dominio tecnologico; - Verificatore: il mancato avanzamento ha prodotto documentazione ridotta rispetto a quanto preventivato, pertanto il Verificatore ha svolto un numero inferiore di ore. Il ruolo dell'Amministratore, invece, ha visto un aumento delle ore rispetto a quanto preventivato, a causa di difficoltà incontrate nell'implementazione delle automazioni (errori, testing, verifica). === Monitoraggio costi e ore #figure( table( columns: 3, [*Ruolo*], [*Ore rimanenti*], [*Budget rimanente*], [Responsabile], [68], [€ 2040], [Amministratore], [86], [€ 1720], [Analista], [101], [€ 2525], [Progettista], [49], [€ 1225], [Programmatore], [196], [€ 2940], [Verificatore], [143], [€ 2145], [Rimanente], [643], [€ 12595], ), caption: "Monitoraggio sprint 1" ) == Sprint 2 dal 13-11-2023 al 20-11-2023 === Obiettivi raggiunti - Riconfigurazione della repository; - Stesura della sezione _Introduzione_ del documento Norme di Progetto; - Stesura della sezione _Processi di supporto_ del documento Norme di Progetto; - Perfezionamento delle automazioni per la compilazione dei documenti; - Implementazione delle automazioni per il versionamento dei documenti; - Contatto con l'azienda Proponente per comunicare l'esito della candidatura; - Meeting con l'azienda Proponente per riflettere sull'analisi dei requisiti e sulle tecnologie da usare; - Inizio dell'individuazione e della stesura degli Use Case. === Obiettivi mancati Gli obiettivi sono stati tutti raggiunti, considerando anche che molti erano obiettivi mancati dello sprint precedente. === Problematiche - Il gruppo ha notato la mancanza di una struttura comune nei verbali, che porta a documenti senza una precisa convenzione e rallentamenti in fase di redazione; - Sono emerse difficoltà nelle modalità di utilizzo della repository, nonostante sia stato dedicato del tempo per la formazione; - Scarsa reattività in fase di review. === Risoluzioni attuate - Per risolvere la problematica di una mancanza di struttura nei verbali, si sono fissate delle convenzioni da seguire nel documento Norme di Progetto; - Per formare meglio il gruppo sulle modalità di utilizzo della repository, è stato dedicato tempo in più per fornire tutorial video e testuali a supporto del gruppo; - Per ovviare alla scarsa reattività in fase di review, il gruppo prende la responsabilità di visionare spesso la casella mail personale per capire quando c'è bisogno di una review o di risolvere una conversation GitHub, oltre a sollecitare i Verificatori via i canali di comunicazione interni del gruppo in caso di mancate revisioni. === Panoramica dei costi effettivi #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [0], [0], [0], [2 (-1)], [2 (-1)], [Carraro], [0], [5 (+1)], [0], [0], [0], [0], [5 (+1)], [Gardin], [0], [4], [0], [0], [0], [0], [4], [Nardo], [0], [0], [3], [0], [0], [0], [3], [Oseliero], [3], [0], [0], [0], [0], [0], [3], [Todesco], [0], [1 (+1)], [3], [0], [0], [0], [4 (+1)], [Zaccone], [0], [2 (+2)], [3], [0], [0], [0], [5 (+2)], [Totale ore], [3], [12 (+4)], [9], [0], [0], [2 (-1)], [26 (+3)], [Costo\ ruolo], [€ 90], [€ 240 (+80)], [€ 225], [€ 0], [€ 0], [€ 30 (-15)], [€ 585 (+65)], ), caption: "Prospetto del consuntivo, sprint 2" ) #let data = ( ("Responsabile", 3, 3), ("Amministratore", 8, 12), ("Analista", 9, 9), ("Progettista", 0, 0), ("Programmatore", 0, 0), ("Verificatore", 3, 2), ) #let x-coordinates = compute-labels-x-coordinate(data, role-chart-size) #let y-coordinates = compute-labels-y-coordinate(data, role-chart-size) #figure({ import draw: * canvas({ chart.barchart(..barchart-config, data) let i = 0 while(i < data.len()) { content( (x-coordinates.at(i).at(0), y-coordinates.at(i).at(0)), [#data.at(i).at(1)], ..barchart-label-config ) content( (x-coordinates.at(i).at(1), y-coordinates.at(i).at(1)), [#data.at(i).at(2)], ..barchart-label-config ) i += 1 } })}, caption: "Suddivisione oraria per ruolo, consuntivo sprint 2", kind: "chart", supplement: "Grafico" ) A causa delle problematiche incontrate, alcuni ruoli hanno visto un monte ore effettivo diverso a quanto preventivato: - Amministratore: la scarsa comprensione delle modalità di utilizzo della repository da parte dei membri del gruppo ha portato gli Amministratori a dedicare delle ore in più mirate al perfezionamento della formazione dei membri del gruppo; - Verificatore: la scarsa reattività in fase di review ha portato un impegno inferiore alle attività di revisione. === Monitoraggio costi e ore #figure( table( columns: 3, [*Ruolo*], [*Ore rimanenti*], [*Budget rimanente*], [Responsabile], [65], [€ 1950], [Amministratore], [74], [€ 1480], [Analista], [92], [€ 2300], [Progettista], [49], [€ 1225], [Programmatore], [196], [€ 2940], [Verificatore], [141], [€ 2115], [Rimanente], [617], [€ 12010], ), caption: "Monitoraggio sprint 2" ) == Sprint 3 dal 20-11-2023 al 27-11-2023 === Obiettivi raggiunti - Proseguimento del processo di individuazione e stesura degli Use Case; - Perfezionamento delle automazioni di versionamento documenti; - Perfezionamento del template usato per i documenti; - Aggiornamento parziale del documento Norme di Progetto; - Studio iniziale della libreria Three.js; - Meeting con l'azienda Proponente per esporre ipotesi e Use Case individuati, richiedere chiarimenti ed avanzare opportune richieste; - Contatto con l'azienda Proponente per fissare il prossimo meeting. === Obiettivi mancati - Aggiornamento completo del documento Piano di Progetto con l'inserimento dei grafici di Gantt e di burndown. === Problematiche Nonostante la realizzazione soddisfacente della maggior parte degli obiettivi concordati, sono emerse alcune criticità durante l'implementazione del progetto: - si è riscontrata una pianificazione non ottimale e superficiale, attribuibile alla mancanza di un dettagliato processo di pianificazione durante la riunione precedente l'avvio dello sprint; - sono sorti problemi a causa della mancata definizione di standard per la creazione dei grafici di Gantt e burndown, comportando una stesura parziale dei paragrafi nel documento Piano di Progetto; - la durata dei meeting ha superato le aspettative a causa di alcune inefficienze temporali; - il gruppo ha rilevato la mancanza di standard per designare le persone responsabili della redazione dei verbali durante lo sprint. === Risoluzioni attuate Le risoluzioni attuate per risolvere i problemi citati in precedenza si concentrano su un'organizzazione e un'attenzione maggiore nel processo di pianificazione, oltre alla definizione di standard relativi ai grafici da inserire nei documenti e relativi allo svolgimento dei meeting e redazione dei rispettivi verbali. In particolare: - è stata prestata una maggiore attenzione nella pianificazione del nuovo sprint, introducendo nella board retrospettiva di Miro una bacheca relativa alle task da svolgere, che sono state tradotte fin da subito in ticket di Jira e assegnati ai rispettivi ruoli; - la durata massima dei meeting di retrospettiva è stata fissata a 90 minuti (_soft limit_); - sono stati definiti degli standard per la realizzazione dei grafici, adottando quelli proposti da Jira; - è stato assegnato all'Amministratore il compito della redazione dei verbali. === Panoramica dei costi effettivi #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [2 (-1)], [0], [0], [0], [0], [0], [2 (-1)], [Carraro], [0], [0], [4], [0], [0], [0], [4], [Gardin], [0], [0], [0], [0], [0], [3], [3], [Nardo], [0], [0], [0], [3], [0], [0], [3], [Oseliero], [0], [0], [4], [0], [0], [0], [4], [Todesco], [0], [4 (+1)], [0], [0], [0], [0], [4 (+1)], [Zaccone], [0], [4 (+1)], [0], [0], [0], [0], [4 (+1)], [Totale ore], [2 (-1)], [8 (+2)], [8], [3], [0], [3], [24 (+1)], [Costo\ ruolo], [€ 60 (-30)], [€ 160 (+40)], [€ 200], [€ 75], [€ 0], [€ 45], [€ 540 (+10)], ), caption: "Prospetto del consuntivo, sprint 3" ) #let data = ( ("Responsabile", 3, 2), ("Amministratore", 6, 8), ("Analista", 8, 8), ("Progettista", 3, 3), ("Programmatore", 0, 0), ("Verificatore", 3, 3), ) #let x-coordinates = compute-labels-x-coordinate(data, role-chart-size) #let y-coordinates = compute-labels-y-coordinate(data, role-chart-size) #figure({ import draw: * canvas({ chart.barchart(..barchart-config, data) let i = 0 while(i < data.len()) { content( (x-coordinates.at(i).at(0), y-coordinates.at(i).at(0)), [#data.at(i).at(1)], ..barchart-label-config ) content( (x-coordinates.at(i).at(1), y-coordinates.at(i).at(1)), [#data.at(i).at(2)], ..barchart-label-config ) i += 1 } })}, caption: "Suddivisione oraria per ruolo, consuntivo sprint 3", kind: "chart", supplement: "Grafico" ) A causa dei problemi incontrati, alcuni ruoli hanno visto un monte ore effettivo diverso a quanto preventivato: - Responsabile: a causa di mancati standard su come effettuare una pianificazione ottimale il responsabile ha impiegato meno ore di quanto previsto; - Amministratore: a causa dei mancati standard sulla realizzazione dei grafici gli Amministratori hanno impiegato più ore finalizzate allo studio sui grafici da adottare. === Monitoraggio costi e ore #figure( table( columns: 3, [*Ruolo*], [*Ore rimanenti*], [*Budget rimanente*], [Responsabile], [63], [€ 1890], [Amministratore], [66], [€ 1320], [Analista], [84], [€ 2100], [Progettista], [46], [€ 1150], [Programmatore], [196], [€ 2940], [Verificatore], [138], [€ 2070], [Rimanente], [593], [€ 11470], ), caption: "Monitoraggio sprint 3" ) == Sprint 4 dal 27-11-2023 al 04-12-2023 === Obiettivi raggiunti - Perfezionamento della stesura degli Use Case individuati finora; - Redazione di una prima versione del documento Analisi dei Requisiti; - Scelta di una data per un eventuale primo meeting con il professor Cardin per ottenere un feedback sull'Analisi dei Requisiti; - Proseguimento della redazione e aggiornamento del documento Norme di Progetto; - Proseguimento periodo di studio di Three.js, finalizzato a: - creazione di scaffali nell'ambiente tridimensionale; - implementazione sistema di _drag and drop_; - parametrizzazione degli elementi presenti nell'applicazione. === Obiettivi mancati Tutti gli obiettivi sono stati raggiunti. === Problematiche Il gruppo ha riportato una scarsa reattività durante il processo di review e verifica, con conseguente rallentamento del lavoro. Le review sono state rallentate anche dalla presenza di numerosi merge conflicts, che il gruppo si è ritrovato a gestire per la prima volta nel progetto. Inoltre si è presa coscienza della necessità di apportare migliorie al processo di gestione di Jira. === Risoluzioni attuate Il gruppo ha preso in considerazione l'utilizzo di Graphite per velocizzare il processo di review e creare pull request brevi. L'adozione di questo strumento, o suoi analoghi, verrà valutata dall'Amministratore. Inoltre, il gruppo ha preso l'impegno di formarsi in maniera approfondita sull'utilizzo di Jira, per migliorare l'amministrazione del progetto. === Panoramica dei costi effettivi #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [3], [0], [0], [0], [0], [0], [3], [Carraro], [0], [0], [3], [0], [2 (+1)], [0], [5 (+1)], [Gardin], [0], [0], [0], [0], [0], [4 (+1)], [4 (+1)], [Nardo], [0], [0], [0], [1], [2], [0], [3], [Oseliero], [0], [0], [4], [0], [0], [0], [4], [Todesco], [0], [2 (-1)], [0], [0], [0], [0], [2 (-1)], [Zaccone], [0], [2 (-1)], [0], [0], [0], [0], [2 (-1)], [Totale ore], [3], [4 (-2)], [7], [1], [4 (+1)], [4 (+1)], [23], [Costo\ ruolo], [€ 90], [€ 80 (-40)], [€ 175], [€ 25], [€ 60 (+15)], [€ 60 (+15)], [€ 490 (-10)], ), caption: "Prospetto del consuntivo, sprint 4" ) #let data = ( ("Responsabile", 3, 3), ("Amministratore", 6, 4), ("Analista", 7, 7), ("Progettista", 1, 1), ("Programmatore", 3, 4), ("Verificatore", 3, 4), ) #let x-coordinates = compute-labels-x-coordinate(data, role-chart-size) #let y-coordinates = compute-labels-y-coordinate(data, role-chart-size) #figure({ import draw: * canvas({ chart.barchart(..barchart-config, data) let i = 0 while(i < data.len()) { content( (x-coordinates.at(i).at(0), y-coordinates.at(i).at(0)), [#data.at(i).at(1)], ..barchart-label-config ) content( (x-coordinates.at(i).at(1), y-coordinates.at(i).at(1)), [#data.at(i).at(2)], ..barchart-label-config ) i += 1 } })}, caption: "Suddivisione oraria per ruolo, consuntivo sprint 4", kind: "chart", supplement: "Grafico" ) A causa dei rallentamenti incontrati, alcuni ruoli hanno visto un monte ore effettivo diverso a quanto preventivato: - Amministratore: l'utilizzo di Jira in maniera approssimativa ha portato ad un monte ore inferiore a quanto previsto; - Verificatore: i numerosi merge conflicts hanno portato a notevoli rallentamenti in fase di review. === Monitoraggio costi e ore #figure( table( columns: 3, [*Ruolo*], [*Ore rimanenti*], [*Budget rimanente*], [Responsabile], [60], [€ 1800], [Amministratore], [62], [€ 1240], [Analista], [77], [€ 1925], [Progettista], [45], [€ 1125], [Programmatore], [192], [€ 2880], [Verificatore], [134], [€ 2010], [Rimanente], [570], [€ 10980], ), caption: "Monitoraggio sprint 4" ) == Sprint 5 dal 04-12-2023 al 11-12-2023 === Obiettivi raggiunti - Perfezionamento sistema di _drag and drop_ nel PoC; - Creazione degli scaffali nel PoC; - Miglioramento e aggiornamento documento Analisi dei Requisiti; - Realizzazione PoC relativo alla creazione e posizionamento di scaffali dell'ambiente di lavoro; - Realizzazione PoC relativo alla lettura e utilizzo di file SVG e comunicazione con database; - Realizzazione PoC che integra l'utilizzo di Docker; - Incontro con Proponente in data 06-12-23; - Incontro con professor Cardin in data 07-12-23; - Redazione del Glossario; - Aggiornamento documento Norme di Progetto; - Aggiornamento documento Piano di Progetto; - Aggiornare vecchi documenti con nuovo template. === Obiettivi mancati - Miglioramento GitHub Actions. === Problematiche Durante il meeting di retrospettiva sono emerse le seguenti problematiche da migliorare: - mancanza di precise convenzioni da adottare riguardanti il codice; - lavoro concentrato principalmente nel weekend; - richiesta di maggiore partecipazione dei membri del gruppo sulle board di Miro. === Risoluzioni attuate Conseguentemente ai problemi rilevati, sono state individuate le relative soluzioni da adottare: - normare le convenzioni di stesura del codice nelle Norme di Progetto; - impegnarsi a fissare delle scadenze infrasettimanali così da ridurre il carico di lavoro nel weekend; - utilizzare le board su Miro con anticipo aggiungendo il proprio feedback. === Panoramica dei costi effettivi #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [4], [0], [0], [0], [4], [Carraro], [3], [0], [0], [0], [2], [0], [5], [Gardin], [0], [0], [4], [0], [0], [0], [4], [Nardo], [0], [2 (-1)], [0], [0], [2], [0], [4 (-1)], [Oseliero], [0], [0], [0], [1 (-1)], [2], [0], [3 (-1)], [Todesco], [0], [0], [0], [0], [0], [3], [3], [Zaccone], [0], [0], [0], [1 (-1)], [2], [0], [3 (-1)], [Totale ore], [3], [2 (-1)], [8], [2 (-2)], [8], [3], [26 (-3)], [Costo\ ruolo], [€ 90], [€ 40 (-20)], [€ 200], [€ 50 (-50)], [€ 120], [€ 45], [€ 545 (-70)], ), caption: "Prospetto del consuntivo, sprint 5" ) #let data = ( ("Responsabile", 3, 3), ("Amministratore", 3, 2), ("Analista", 8, 8), ("Progettista", 4, 2), ("Programmatore", 8, 8), ("Verificatore", 3, 3), ) #let x-coordinates = compute-labels-x-coordinate(data, role-chart-size) #let y-coordinates = compute-labels-y-coordinate(data, role-chart-size) #figure({ import draw: * canvas({ chart.barchart(..barchart-config, data) let i = 0 while(i < data.len()) { content( (x-coordinates.at(i).at(0), y-coordinates.at(i).at(0)), [#data.at(i).at(1)], ..barchart-label-config ) content( (x-coordinates.at(i).at(1), y-coordinates.at(i).at(1)), [#data.at(i).at(2)], ..barchart-label-config ) i += 1 } })}, caption: "Suddivisione oraria per ruolo, consuntivo sprint 5", kind: "chart", supplement: "Grafico" ) Per produrre una prima versione dei PoC, i Progettisti (e in parte il Responsabile e l'Amministratore) hanno impiegato ore produttive come Programmatori, questo ha in parte significato una riduzione delle ore produttive previste per il ruolo assegnato. === Monitoraggio costi e ore #figure( table( columns: 3, [*Ruolo*], [*Ore rimanenti*], [*Budget rimanente*], [Responsabile], [57], [€ 1710], [Amministratore], [60], [€ 1200], [Analista], [69], [€ 1725], [Progettista], [43], [€ 1075], [Programmatore], [184], [€ 2760], [Verificatore], [131], [€ 1965], [Rimanente], [544], [€ 10435], ), caption: "Monitoraggio sprint 5" ) == Sprint 6 dal 11-12-2023 al 18-12-2023 === Obiettivi raggiunti - Avanzamento del PoC A con: - miglioramento grafico degli scaffali; - posizionamento automatico dei bin nello scaffale al momento della sua creazione; - implementazione visualizzazione prodotti dei bin tramite alert JavaScript. - Aggiornamento documento Norme di Progetto; - Aggiornamento documento Analisi dei Requisiti con: - refactoring degli Use Case secondo le indicazioni del Professor Cardin; - redazione requisiti funzionali; - redazione requisiti di qualità; - redazione requisiti di vincolo. - Redazione introduzione Piano di Qualifica; - Meeting con l'azienda Proponente per: - esporre il PoC A; - aggiornare sullo stato dei lavori; - chiedere feedback sui requisiti non funzionali. - Conversione del Glossario in JSON per automatizzare l'individuazione dei termini nei documenti. === Obiettivi mancati - Migliorare GitHub Actions risolvendo eventuali problemi o aggiungendo funzionalità; - Implementazione PoC esplorativo per il front-end. === Problematiche Durante il meeting di retrospettiva sono emerse le seguenti problematiche da migliorare: - mancata comunicazione di situazioni di difficoltà o problemi che hanno portato a rallentamenti nella produzione di un PoC per il front-end; - la stesura del documento Norme di Progetto ha una velocità di avanzamento troppo bassa. === Risoluzioni attuate Conseguentemente ai problemi rilevati, sono state individuate le relative soluzioni da adottare: - si richiede ai componenti del gruppo una comunicazione rapida delle difficoltà e problemi, non appena questi si presentano; - il numero di persone assegnate alla redazione delle Norme di Progetto verrà incrementato da due a tre, in modo da garantire la produzione di un maggior numero di sezioni durante lo sprint. === Panoramica dei costi effettivi #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [4], [0], [0], [0], [4], [Carraro], [3], [0], [0], [0], [0], [0], [3], [Gardin], [0], [0], [4], [0], [0], [0], [4], [Nardo], [0], [3], [0], [0], [0], [0], [3], [Oseliero], [0], [0], [0], [1], [2 (-1)], [0], [3 (-1)], [Todesco], [0], [0], [0], [0], [0], [3], [3], [Zaccone], [0], [0], [0], [1], [3], [0], [4], [Totale ore], [3], [3], [8], [2], [5 (-1)], [3], [24 (-1)], [Costo\ ruolo], [€ 90], [€ 60], [€ 200], [€ 50], [€ 75 (-15)], [€ 45], [€ 520 (-15)], ), caption: "Prospetto del consuntivo, sprint 6" ) #let data = ( ("Responsabile", 3, 3), ("Amministratore", 3, 3), ("Analista", 8, 8), ("Progettista", 2, 2), ("Programmatore", 6, 5), ("Verificatore", 3, 3), ) #let x-coordinates = compute-labels-x-coordinate(data, role-chart-size) #let y-coordinates = compute-labels-y-coordinate(data, role-chart-size) #figure({ import draw: * canvas({ chart.barchart(..barchart-config, data) let i = 0 while(i < data.len()) { content( (x-coordinates.at(i).at(0), y-coordinates.at(i).at(0)), [#data.at(i).at(1)], ..barchart-label-config ) content( (x-coordinates.at(i).at(1), y-coordinates.at(i).at(1)), [#data.at(i).at(2)], ..barchart-label-config ) i += 1 } })}, caption: "Suddivisione oraria per ruolo, consuntivo sprint 6", kind: "chart", supplement: "Grafico" ) Il ruolo di Programmatore presenta un monte ore effettivo minore rispetto a quello preventivato a causa di problemi tecnici che hanno interrotto la lavorazione del PoC. === Monitoraggio costi e ore #figure( table( columns: 3, [*Ruolo*], [*Ore rimanenti*], [*Budget rimanente*], [Responsabile], [54], [€ 1620], [Amministratore], [57], [€ 1140], [Analista], [61], [€ 1525], [Progettista], [41], [€ 1025], [Programmatore], [179], [€ 2685], [Verificatore], [128], [€ 1920], [Rimanente], [520], [€ 9915], ), caption: "Monitoraggio sprint 6" ) == Sprint 7 dal 18-12-2023 al 25-12-2023 === Obiettivi raggiunti - Integrazione dei PoC realizzati in un unico PoC; - Individuazione di metriche di base per il Piano di Qualifica; - Aggiornamento del documento Norme di Progetto; - Automatizzata l'individuazione dei termini del glossario nei documenti. === Obiettivi mancati - Implementazione del tracciamento requisito-fonte nel documento Analisi dei Requisiti; - revisione generale del documento per verifcare la presenza e la correttezza di tutti gli Use Case e requisiti necessari; - Correzione di bug presenti nelle GitHub Actions. === Problematiche Durante il meeting di retrospettiva sono sorte le seguenti problematiche: - il pool mensile di automatismi inclusi nel piano gratuito relativi ai ticket di Jira è stato esaurito; - lentezza nell'approvazione delle correzioni richieste nelle review; - nelle review delle pull request alcuni commenti risultano essere poco chiari e/o sbrigativi; - il progresso relativo al documento Norme di Progetto è risultato scarso in confronto con gli sprint precedenti, e in ritardo rispetto a quanto pianificato; - il tracciamento delle attività relative al PoC non ha lo stesso livello di precisione di quello delle attività documentali. === Risoluzioni attuate - Richiedere l'upgrade gratuito a Jira Standard per progetti open source; - Notificare, tramite i canali dedicati, chi debba apportare correzioni così da velocizzare i tempi di approvazione; - Impegnarsi a fornire commenti di review più precisi: - indicando con precisione la natura dell'errore e, se utile, la sua localizzazione all'interno della riga; - fornendo una possibile correzione, quando appropriato; - nel caso di più occorrenze dello stesso errore, segnalarle tutte. Per evitare ripetizioni, fornire una valutazione della prima occorrenza ed inserire un riferimento a tale conversazione nelle occorrenze successive. - Per accelerare il lavoro sulle Norme di Progetto, chi ha redatto le Norme di Progetto nel corso degli sprint precedenti continuerà l'affiancamento nel corso dello sprint successivo; - La natura esplorativa del PoC richiede flessibilità nella pianificazione, ma si sottolinea la necessità di continuare a tracciare le attività per riferimento futuro. === Panoramica dei costi effettivi #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [3 (-1)], [0], [0], [0], [0], [3 (-1)], [Carraro], [0], [0], [0], [0], [3], [0], [3], [Gardin], [0], [0], [0], [3], [0], [0], [3], [Nardo], [2 (-1)], [0], [0], [0], [0], [0], [2 (-1)], [Oseliero], [0], [0], [0], [0], [2], [2], [4], [Todesco], [0], [0], [0], [2 (-1)], [0], [0], [2 (-1)], [Zaccone], [0], [0], [1 (-2)], [0], [0], [0], [1 (-2)], [Totale ore], [2 (-1)], [3 (-1)], [1 (-2)], [5 (-1)], [5], [2], [18 (-5)], [Costo\ ruolo], [€ 60 (-30)], [€ 60 (-20)], [€ 25 (-50)], [€ 125 (-25)], [€ 75], [€ 30], [€ 375 (-125)], ), caption: "Prospetto del consuntivo, sprint 7" ) #let data = ( ("Responsabile", 3, 2), ("Amministratore", 4, 3), ("Analista", 3, 1), ("Progettista", 6, 5), ("Programmatore", 5, 5), ("Verificatore", 2, 2), ) #let x-coordinates = compute-labels-x-coordinate(data, role-chart-size) #let y-coordinates = compute-labels-y-coordinate(data, role-chart-size) #figure({ import draw: * canvas({ chart.barchart(..barchart-config, data) let i = 0 while(i < data.len()) { content( (x-coordinates.at(i).at(0), y-coordinates.at(i).at(0)), [#data.at(i).at(1)], ..barchart-label-config ) content( (x-coordinates.at(i).at(1), y-coordinates.at(i).at(1)), [#data.at(i).at(2)], ..barchart-label-config ) i += 1 } })}, caption: "Suddivisione oraria per ruolo, consuntivo sprint 7", kind: "chart", supplement: "Grafico" ) Diversi ruoli risultano avere un monte ore minore rispetto a quello preventivato, a causa di rallentamenti nella stesura delle Norme di Progetto e, per quanto riguarda l'Analista, un rallentamento dovuto alla mancanza di materiale su cui lavorare: il materiale necessario era infatti presente in un branch di cui non era ancora stata fatta una pull request. === Monitoraggio costi e ore #figure( table( columns: 3, [*Ruolo*], [*Ore rimanenti*], [*Budget rimanente*], [Responsabile], [52], [€ 1560], [Amministratore], [54], [€ 1080], [Analista], [60], [€ 1500], [Progettista], [36], [€ 900], [Programmatore], [174], [€ 2610], [Verificatore], [126], [€ 1890], [Rimanente], [502], [€ 9540], ), caption: "Monitoraggio sprint 7" ) == Sprint 8 dal 26-12-2023 al 31-12-2023 === Obiettivi raggiunti - Miglioramento del Glossario con gestione di plurali e acronimi dei termini ed evidenziazione _case insensitive_; - Implementato il tracciamento requisito-fonte nell'Analisi dei Requisiti; - Aggiornamento del documento Norme di Progetto; - Realizzato sito web per la documentazione; - Automatizzata l'individuazione dei termini del Glossario nei documenti. - Realizzazione di una dashboard preliminare Grafana; - Perfezionamento PoC finale. === Obiettivi mancati - La dashboard di monitoraggio non implementa tutte le metriche individuate nel Piano di Qualifica; - Rimane da comprendere a fondo le implicazioni della scelta tra Next.js ed Express.js; - Permangono bug nelle GitHub Action. === Problematiche Durante il meeting di retrospettiva sono sorte le seguenti problematiche: - i lavori hanno subito rallentamenti dovuti al periodo di festività. === Risoluzioni attuate Nessuna. === Panoramica dei costi effettivi #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [4 (+1)], [0], [0], [0], [0], [4 (+1)], [Carraro], [0], [0], [0], [0], [5 (+2)], [0], [5 (+2)], [Gardin], [0], [2 (+2)], [0], [2 (-1)], [0], [0], [4 (+1)], [Nardo], [4], [0], [0], [0], [0], [0], [4], [Oseliero], [0], [0], [0], [0], [0], [4], [4], [Todesco], [0], [0], [0], [3], [0], [0], [3], [Zaccone], [0], [0], [3], [0], [0], [0], [3], [Totale ore], [4], [6 (+3)], [3], [5 (-1)], [5 (+2)], [4], [27 (+4)], [Costo\ ruolo], [€ 120], [€ 120 (+60)], [€ 75], [€ 125 (-25)], [€ 75 (+30)], [€ 60], [€ 575 (+65)], ), caption: "Prospetto del consuntivo, sprint 8" ) #let data = ( ("Responsabile", 4, 4), ("Amministratore", 3, 6), ("Analista", 3, 3), ("Progettista", 6, 5), ("Programmatore", 3, 5), ("Verificatore", 4, 4), ) #let x-coordinates = compute-labels-x-coordinate(data, role-chart-size) #let y-coordinates = compute-labels-y-coordinate(data, role-chart-size) #figure({ import draw: * canvas({ chart.barchart(..barchart-config, data) let i = 0 while(i < data.len()) { content( (x-coordinates.at(i).at(0), y-coordinates.at(i).at(0)), [#data.at(i).at(1)], ..barchart-label-config ) content( (x-coordinates.at(i).at(1), y-coordinates.at(i).at(1)), [#data.at(i).at(2)], ..barchart-label-config ) i += 1 } })}, caption: "Suddivisione oraria per ruolo, consuntivo sprint 8", kind: "chart", supplement: "Grafico" ) La ricerca di una valida soluzione per implementare la dashboard di monitoraggio ha richiesto un impegno maggiore rispetto a quanto preventivato. La scelta di adottare Grafana comporterà costi di adozione più alti rispetto a soluzioni standard. La contemporanea implementazione del sito web per la documentazione ha accentuato la necessità di avvalersi della figura dell'Amministratore. === Monitoraggio costi e ore #figure( table( columns: 3, [*Ruolo*], [*Ore rimanenti*], [*Budget rimanente*], [Responsabile], [48], [€ 1440], [Amministratore], [48], [€ 960], [Analista], [57], [€ 1425], [Progettista], [31], [€ 775], [Programmatore], [169], [€ 2535], [Verificatore], [122], [€ 1830], [Rimanente], [475], [€ 8965], ), caption: "Monitoraggio sprint 8" ) == Sprint 9 dal 01-01-2024 al 08-01-2024 === Obiettivi raggiunti Tutti gli obiettivi dello sprint sono stati raggiunti. === Obiettivi mancati Nessuno. === Problematiche Durante il meeting di retrospettiva sono sorte le seguenti problematiche: - le norme di formattazione del testo non sono state rispettate in alcune sezioni dei documenti, specialmente nelle sezioni redatte meno di recente; - le norme per l'inclusione di riferimenti a documenti esterni sono imprecise; - alcuni ticket non urgenti vengono erroneamente creati ed inseriti nel backlog dello sprint in corso, falsando la reportistica di Jira. === Risoluzioni attuate - Durante la verifica dei documenti in ottica RTB, il Verificatore controllerà anche l'uso conforme della formattazione del testo; - Qualora il Redattore desideri includere un riferimento ad un documento esterno, dovrà sincerarsi che: + i riferimenti ai documenti riportino il numero di versione più recente; + i link ai documenti siano riportati nella sezione Riferimenti; + i link ai documenti siano riportati per esteso; + i link puntino al documento PDF contenuto nel branch `main`. - I ticket non urgenti saranno aggiunti al backlog generale e non a quello dello sprint in corso. === Panoramica dei costi effettivi #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [3 (-2)], [0], [0], [0], [0], [3 (-2)], [Carraro], [0], [0], [0], [0], [0], [3 (-1)], [3 (-1)], [Gardin], [0], [1 (-4)], [0], [1 (+1)], [0], [0], [2 (-3)], [Nardo], [0], [0], [0], [0], [0], [3 (-1)], [3 (-1)], [Oseliero], [0], [0], [4 (-1)], [0], [0], [0], [4 (-1)], [Todesco], [0], [0], [0], [0], [0], [3 (-1)], [3 (-1)], [Zaccone], [3 (-1)], [0], [0], [0], [0], [0], [3 (-1)], [Totale ore], [3 (-1)], [4 (-6)], [4 (-1)], [1 (+1)], [0], [9 (-3)], [21 (-10)], [Costo\ ruolo], [€ 90 (-30)], [€ 80 (-120)], [€ 100 (-25)], [€ 25 (+25)], [€ 0], [€ 135 (-45)], [€ 430 (-195)], ), caption: "Prospetto del consuntivo, sprint 9" ) #let data = ( ("Responsabile", 4, 3), ("Amministratore", 10, 4), ("Analista", 5, 4), ("Progettista", 0, 1), ("Programmatore", 0, 0), ("Verificatore", 12, 9), ) #let x-coordinates = compute-labels-x-coordinate(data, role-chart-size) #let y-coordinates = compute-labels-y-coordinate(data, role-chart-size) #figure({ import draw: * canvas({ chart.barchart(..barchart-config, data) let i = 0 while(i < data.len()) { content( (x-coordinates.at(i).at(0), y-coordinates.at(i).at(0)), [#data.at(i).at(1)], ..barchart-label-config ) content( (x-coordinates.at(i).at(1), y-coordinates.at(i).at(1)), [#data.at(i).at(2)], ..barchart-label-config ) i += 1 } })}, caption: "Suddivisione oraria per ruolo, consuntivo sprint 9", kind: "chart", supplement: "Grafico" ) La pianificazione delle attività per lo sprint 9 è stata conservativa. L'entità di alcune attività, specialmente quelle relative alle automazioni e alla dashboard, si sono rivelate sensibilmente minori del previsto. Il Progettista, inizialmente non previsto, è stato interpellato per la realizzazione della presentazione per il colloquio RTB con il Professor Cardin. === Monitoraggio costi e ore #figure( table( columns: 3, [*Ruolo*], [*Ore rimanenti*], [*Budget rimanente*], [Responsabile], [45], [€ 1350], [Amministratore], [44], [€ 880], [Analista], [53], [€ 1325], [Progettista], [30], [€ 750], [Programmatore], [169], [€ 2535], [Verificatore], [113], [€ 1695], [Rimanente], [454], [€ 8535], ), caption: "Monitoraggio sprint 9" ) == Sprint 10 dal 08-01-2024 al 14-01-2024 === Obiettivi raggiunti - I problemi prestazionali del PoC sono stati risolti con successo; - Le automazioni hanno subito un refactoring al fine di migliorarne l'affidabilità, la flessibilità e il riuso; - I documenti Piano di Qualifica, Piano di Progetto sono stati verificati in vista della valutazione RTB; - Preparazione della presentazione Google Slides a supporto della revisione RTB. === Obiettivi mancati - La dashboard di monitoraggio non è stata ampliata. === Problematiche Durante il meeting di retrospettiva sono sorte le seguenti problematiche: - la comunicazione tra i ruoli è risultata non allineata (_siloed_), e ha causato confusione e rallentamenti del processo di revisione; - riscontrato uno sbilanciamento dell'impegno dei singoli membri del gruppo. === Risoluzioni attuate I membri del gruppo si impegneranno a comunicare in maniera più tempestiva e precisa modifiche apportate e/o aggiornamenti alla configurazione degli strumenti di supporto. L'impegno individuale dei membri risulta sbilanciato a causa dell'imminenete sessione d'esame invernale. Pertanto, la pianificazione dei prossimi sprint terrà conto della ridotta disponibilità di tempo. È previsto che la situazione migliorerà entro il termine dello sprint 13. === Panoramica dei costi effettivi #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [0], [0], [0], [3], [3], [Carraro], [0], [0], [0], [1 (+1)], [0], [2], [3 (+1)], [Gardin], [0], [2], [0], [0], [0], [0], [2], [Nardo], [0], [0], [0], [0], [2], [0], [2], [Oseliero], [0], [0], [2], [0], [0], [0], [2], [Todesco], [1 (+1)], [0], [0], [0], [2], [0], [3 (+1)], [Zaccone], [1 (-1)], [0], [0], [0], [0], [3], [4 (-1)], [Totale ore], [2], [2], [2], [1 (+1)], [4], [8], [19 (+1)], [Costo\ ruolo], [€ 60], [€ 40], [€ 50], [€ 25 (+25)], [€ 60], [€ 120], [€ 355 (+25)], ), caption: "Prospetto del consuntivo, sprint 10" ) #let data = ( ("Responsabile", 2, 2), ("Amministratore", 2, 2), ("Analista", 2, 2), ("Progettista", 0, 1), ("Programmatore", 4, 4), ("Verificatore", 8, 8), ) #let x-coordinates = compute-labels-x-coordinate(data, role-chart-size) #let y-coordinates = compute-labels-y-coordinate(data, role-chart-size) #figure({ import draw: * canvas({ chart.barchart(..barchart-config, data) let i = 0 while(i < data.len()) { content( (x-coordinates.at(i).at(0), y-coordinates.at(i).at(0)), [#data.at(i).at(1)], ..barchart-label-config ) content( (x-coordinates.at(i).at(1), y-coordinates.at(i).at(1)), [#data.at(i).at(2)], ..barchart-label-config ) i += 1 } })}, caption: "Suddivisione oraria per ruolo, consuntivo sprint 10", kind: "chart", supplement: "Grafico" ) La presenza del Progettista, non pianificata, deriva dalla necessità di decidere quale software adottare (tra Next.js ed Express.js) per l'implementazione di un componente del PoC. Entrambe le tecnologie sono state approfondite ed implementate durante lo sviluppo dei PoC, ma non era ancora stata presa una scelta definitiva. Inoltre, la redazione della presentazione per il colloquio RTB ha nuovamente richiesto l'intervento del Progettista. === Monitoraggio costi e ore #figure( table( columns: 3, [*Ruolo*], [*Ore rimanenti*], [*Budget rimanente*], [Responsabile], [43], [€ 1290], [Amministratore], [42], [€ 840], [Analista], [51], [€ 1275], [Progettista], [29], [€ 725], [Programmatore], [165], [€ 2475], [Verificatore], [105], [€ 1575], [Rimanente], [435], [€ 8180], ), caption: "Monitoraggio sprint 10" ) == Sprint 11 dal 14-01-2024 al 21-01-2024 === Obiettivi raggiunti - Inviata la candidatura al Professor Cardin per il colloquio RTB; - Al Piano di Progetto sono state apportate modifiche minori per migliorare la leggibilità dei dati; - Il sito web è accessibile in ogni sua parte e comprende i riferimenti di ogni documento prodotto dal gruppo; - I contenuti della presentazione per il colloquio RTB sono stati definiti e il documento è stato completato. === Obiettivi mancati Nessuno. === Problematiche Durante il meeting di retrospettiva sono sorte le seguenti problematiche: - carico di lavoro asimmetrico tra i membri del gruppo a causa dei differenti esami da sostenere. === Risoluzioni attuate Nessuna. La situazione di carico di lavoro asimmetrico è destinata a migliorare con l'approcciarsi della fine della sessione d'esami invernale. === Panoramica dei costi effettivi #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [1 (-1)], [0], [0], [0], [1 (-1)], [Carraro], [0], [0], [0], [0], [0], [1 (-1)], [1 (-1)], [Gardin], [0], [0], [0], [0], [0], [1 (-1)], [1 (-1)], [Nardo], [2 (-1)], [0], [0], [0], [0], [0], [2 (-1)], [Oseliero], [0], [0], [1], [0], [0], [0], [1], [Todesco], [0], [3], [0], [0], [0], [0], [3], [Zaccone], [0], [0], [0], [0], [0], [2], [2], [Totale ore], [2 (-1)], [3], [2 (-1)], [0], [0], [4 (-2)], [11 (-4)], [Costo\ ruolo], [€ 60 (-30)], [€ 60], [€ 50 (-25)], [€ 0], [€ 0], [€ 60 (-30)], [€ 230 (-85)], ), caption: "Prospetto del consuntivo, sprint 11" ) #let data = ( ("Responsabile", 3, 2), ("Amministratore", 3, 3), ("Analista", 3, 2), ("Progettista", 0, 0), ("Programmatore", 0, 0), ("Verificatore", 6, 4), ) #let x-coordinates = compute-labels-x-coordinate(data, role-chart-size) #let y-coordinates = compute-labels-y-coordinate(data, role-chart-size) #figure({ import draw: * canvas({ chart.barchart(..barchart-config, data) let i = 0 while(i < data.len()) { content( (x-coordinates.at(i).at(0), y-coordinates.at(i).at(0)), [#data.at(i).at(1)], ..barchart-label-config ) content( (x-coordinates.at(i).at(1), y-coordinates.at(i).at(1)), [#data.at(i).at(2)], ..barchart-label-config ) i += 1 } })}, caption: "Suddivisione oraria per ruolo, consuntivo sprint 11", kind: "chart", supplement: "Grafico" ) La necessità dei ruoli di Responsabile e di Analista è stata minore rispetto alle attese. Anche il Verificatore ha lavorato meno del previsto, visto l'entità minima delle modifiche ai documenti. Tale figura rimane comunque la più impegnata, a causa della necessità di verificare la presentazione per il colloquio RTB. === Monitoraggio costi e ore #figure( table( columns: 3, [*Ruolo*], [*Ore rimanenti*], [*Budget rimanente*], [Responsabile], [41], [€ 1230], [Amministratore], [39], [€ 780], [Analista], [49], [€ 1225], [Progettista], [29], [€ 725], [Programmatore], [165], [€ 2475], [Verificatore], [101], [€ 1515], [Rimanente], [424], [€ 7950], ), caption: "Monitoraggio sprint 11" ) == Sprint 12 dal 21-01-2024 al 28-01-2024 === Obiettivi raggiunti - Colloquio con il Professor Cardin superato con luce "ampiamente verde"; - Aggiunta di grafici al Piano di Progetto: - suddivisione oraria per ruolo per preventivi e consuntivi. === Obiettivi mancati - Estensione dei termini di Glossario. === Problematiche Nessuna. === Risoluzioni attuate Nessuna. === Panoramica dei costi effettivi #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [0], [1], [0], [0], [1], [Carraro], [0], [0], [1 (+1)], [1], [0], [0], [2 (+1)], [Gardin], [0], [0], [0], [1], [0], [0], [1], [Nardo], [1], [0], [0], [0], [0], [0], [1], [Oseliero], [0], [0], [0], [0], [0], [1], [1], [Todesco], [0], [1], [0], [0], [0], [0], [1], [Zaccone], [0], [0], [0], [0], [0], [1], [1], [Totale ore], [1], [1], [1 (+1)], [3], [0], [2], [8 (+1)], [Costo\ ruolo], [€ 30], [€ 20], [€ 25 (+25)], [€ 75], [€ 0], [€ 30], [€ 180 (+25)], ), caption: "Prospetto del consuntivo, sprint 12" ) #let data = ( ("Responsabile", 1, 1), ("Amministratore", 1, 1), ("Analista", 0, 1), ("Progettista", 3, 3), ("Programmatore", 0, 0), ("Verificatore", 2, 2), ) #let x-coordinates = compute-labels-x-coordinate(data, role-chart-size) #let y-coordinates = compute-labels-y-coordinate(data, role-chart-size) #figure({ import draw: * canvas({ chart.barchart(..barchart-config, data) let i = 0 while(i < data.len()) { content( (x-coordinates.at(i).at(0), y-coordinates.at(i).at(0)), [#data.at(i).at(1)], ..barchart-label-config ) content( (x-coordinates.at(i).at(1), y-coordinates.at(i).at(1)), [#data.at(i).at(2)], ..barchart-label-config ) i += 1 } })}, caption: "Suddivisione oraria per ruolo, consuntivo sprint 12", kind: "chart", supplement: "Grafico" ) Il totale delle ore di lavoro preventivate è stato in gran parte rispettato. Tuttavia, il ruolo di Analista è stato attivato per correggere un errore di forma riscontrato nel calcolo dei codici identificativi dei requisiti. === Monitoraggio costi e ore #figure( table( columns: 3, [*Ruolo*], [*Ore rimanenti*], [*Budget rimanente*], [Responsabile], [40], [€ 1200], [Amministratore], [38], [€ 760], [Analista], [48], [€ 1200], [Progettista], [26], [€ 650], [Programmatore], [165], [€ 2475], [Verificatore], [99], [€ 1485], [Rimanente], [416], [€ 7770], ), caption: "Monitoraggio sprint 12" ) == Sprint 13 dal 28-01-2024 al 04-02-2024 === Obiettivi raggiunti - Preparazione della pianificazione dello sprint 14 a seguito del risultato del colloquio RTB sostenuto con il Professor Cardin, ricevuto il 31/01/2024. === Obiettivi mancati Nessuno. === Problematiche Il feedback ricevuto dal Professor Cardin evidenzia diverse lacune nel documento Analisi dei Requisiti. Sarà dunque necessario investire risorse per correggere e migliorare il documento. Ciò potrebbe influire negativamente sull'avanzamento del progetto. === Risoluzioni attuate Nessuna. === Panoramica dei costi effettivi #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [0], [0], [0], [0], [0], [Carraro], [0], [0], [0], [0], [0], [0], [0], [Gardin], [3 (+1)], [0], [0], [0], [0], [0], [3 (+1)], [Nardo], [0], [0], [0], [0], [0], [0], [0], [Oseliero], [0], [1], [0], [0], [0], [0], [1], [Todesco], [0], [0], [0], [0], [0], [0], [0], [Zaccone], [0], [0], [0], [0], [0], [0], [0], [Totale ore], [3 (+1)], [1], [0], [0], [0], [0], [4 (+1)], [Costo\ ruolo], [€ 90 (+30)], [€ 20], [€ 0], [€ 0], [€ 0], [€ 0], [€ 110 (+30)], ), caption: "Prospetto del consuntivo, sprint 13" ) #let data = ( ("Responsabile", 2, 3), ("Amministratore", 1, 1), ("Analista", 0, 0), ("Progettista", 0, 0), ("Programmatore", 0, 0), ("Verificatore", 0, 0), ) #let x-coordinates = compute-labels-x-coordinate(data, role-chart-size) #let y-coordinates = compute-labels-y-coordinate(data, role-chart-size) #figure({ import draw: * canvas({ chart.barchart(..barchart-config, data) let i = 0 while(i < data.len()) { content( (x-coordinates.at(i).at(0), y-coordinates.at(i).at(0)), [#data.at(i).at(1)], ..barchart-label-config ) content( (x-coordinates.at(i).at(1), y-coordinates.at(i).at(1)), [#data.at(i).at(2)], ..barchart-label-config ) i += 1 } })}, caption: "Suddivisione oraria per ruolo, consuntivo sprint 13", kind: "chart", supplement: "Grafico" ) Lo sprint 13 è stato caratterizzato da un momento di pausa, dovuto alla concomitanza degli esami, conclusosi mercoledì 31/01/2024 con la ricezione del feedback da parte del Professor Cardin. Nel corso dei giorni rimanenti, il Responsabile ha aggiornato la pianificazione per adeguarla al diverso contesto di lavoro. === Monitoraggio costi e ore #figure( table( columns: 3, [*Ruolo*], [*Ore rimanenti*], [*Budget rimanente*], [Responsabile], [37], [€ 1110], [Amministratore], [37], [€ 740], [Analista], [48], [€ 1200], [Progettista], [26], [€ 650], [Programmatore], [165], [€ 2475], [Verificatore], [99], [€ 1485], [Rimanente], [412], [€ 7660], ), caption: "Monitoraggio sprint 13" ) == Sprint 14 dal 04-02-2024 al 11-02-2024 === Obiettivi raggiunti - Revisione, correzione ed estensione del documento #adr secondo il feedback ricevuto dal #cardin; - Estensione delle metriche riportate nella dashboard di monitoraggio; - Estensione dei termini di Glossario per riflettere i nuovi strumenti adottati; - Contattato il Proponente per fornire aggiornamenti sullo stato dei lavori e programmare gli incontri successivi al colloquio RTB. === Obiettivi mancati Nessuno. === Problematiche Durante il meeting di retrospettiva sono sorte le seguenti problematiche: - il carico di lavoro sul Verificatore è stato elevato; - numerosi conflitti di _merge_ dovuti al lavoro parallelo su ticket associati allo stesso documento; - la board Miro ha mostrato scarsità di riscontro su _Keep doings_ e _Improvements_ prima dell'incontro di retrospettiva. === Risoluzioni attuate - I conflitti di _merge_ sono inevitabili quando più branch insistono sullo stesso documento. Durante questo sprint la maggior parte del lavoro è avvenuta sul documento #adr. Si cercherà di evitare la sovrapposizione di lavoro sui documenti coordinando il lavoro di redattori e Verificatori; - Il Responsabile ha sottolineato l'importanza di individuare _Keep doings_ e _Improvements_ prima dell'incontro di retrospettiva. Non si tratta di un'attività facoltativa, ma di un processo chiave nel miglioramento continuo del gruppo. === Panoramica dei costi effettivi #figure( table( columns: 8, [*Membro*], [*Responsabile*], [*Amministratore*], [*Analista*], [*Progettista*], [*Programmatore*], [*Verificatore*], [*Totale*], [Banzato], [0], [0], [3], [0], [0], [0], [3], [Carraro], [0], [1], [1], [0], [0], [2], [4], [Gardin], [3], [0], [2], [0], [0], [0], [5], [Nardo], [0], [0], [2], [0], [0], [3], [5], [Oseliero], [0], [2], [0], [0], [0], [2], [4], [Todesco], [0], [0], [0], [1], [0], [3], [4], [Zaccone], [0], [0], [0], [1], [0], [3], [4], [Totale ore], [3], [3], [8], [2], [0], [13], [29], [<NAME>], [90], [60], [200], [50], [0], [195], [595], ), caption: "Prospetto del consuntivo, sprint 14" ) #let data = ( ("Responsabile", 3, 3), ("Amministratore", 3, 3), ("Analista", 8, 8), ("Progettista", 2, 2), ("Programmatore", 0, 0), ("Verificatore", 13, 13), ) #let x-coordinates = compute-labels-x-coordinate(data, role-chart-size) #let y-coordinates = compute-labels-y-coordinate(data, role-chart-size) #figure({ import draw: * canvas({ chart.barchart(..barchart-config, data) let i = 0 while(i < data.len()) { content( (x-coordinates.at(i).at(0), y-coordinates.at(i).at(0)), [#data.at(i).at(1)], ..barchart-label-config ) content( (x-coordinates.at(i).at(1), y-coordinates.at(i).at(1)), [#data.at(i).at(2)], ..barchart-label-config ) i += 1 } })}, caption: "Suddivisione oraria per ruolo, consuntivo sprint 14", kind: "chart", supplement: "Grafico" ) La pianificazione di questo sprint è stata precisa e rispettata. Il lavoro del Verificatore è stato particolarmente intenso a causa delle numerose modifiche apportate al documento #adr. === Monitoraggio costi e ore #figure( table( columns: 3, [*Ruolo*], [*Ore rimanenti*], [*Budget rimanente*], [Responsabile], [34], [1020], [Amministratore], [34], [680], [Analista], [40], [1000], [Progettista], [24], [600], [Programmatore], [165], [2475], [Verificatore], [86], [1290], [Rimanente], [383], [7065], ), caption: "Monitoraggio, sprint 14" ) // == Sprint n dal D1-M1-2024 al D2-M2-2024 // === Obiettivi raggiunti // === Obiettivi mancati // === Problematiche // Durante il meeting di retrospettiva sono sorte le seguenti problematiche: // === Risoluzioni attuate // === Panoramica dei costi effettivi // TABLE // TODO // === Monitoraggio costi e ore // TABLE
https://github.com/7sDream/fonts-and-layout-zhCN
https://raw.githubusercontent.com/7sDream/fonts-and-layout-zhCN/master/chapters/02-concepts/dimension/adv-width.typ
typst
Other
#import "/template/template.typ": web-page-template #import "/template/components.typ": note #import "/lib/glossary.typ": tr #show: web-page-template // ### Advance widths === #tr[advance width] // You may have also noticed that while we call it an em *square*, there's nothing really square about it. It's more of an em *rectangle*. Let's think about the dimensions of this rectangle. 你也许已经注意到,虽然我们把它称作em*方*框,但它实际上并不是正方形,也许称它为em*矩形框*更为合适。让我们仔细看看这个矩形的尺寸。 // Let's first assume that we're designing a horizontal font; in that case, one of the most important dimensions of each glyph is the width of the em square - not just the black part of the glyph, but also including the space around it. You will often hear this referred to as the *advance width*, or the *horizontal advance*. This is because most layout systems, working on the typographic model we saw at the beginning of this book, keep track of the X and Y co-ordinates of where they are going to write glyphs to the screen or page; after each glyph, the writing position advances. For a horizontal font, a variable within the layout system (sometimes called the *cursor*) advances along the X dimension, and the amount that the cursor advances is... the horizontal advance. 首先假定我们是在设计一个沿水平方向书写的字体。这样的话,每个#tr[glyph]最重要的一个尺寸就是#tr[em square]的宽度。这不仅包括#tr[glyph]中被填充为黑色的那部分,也包括了其周围的空白空间。这个尺寸经常被称为*#tr[advance width]*,或者*#tr[horizontal advance]*。这是因为,遵循本书介绍的这种#tr[typography]模型的占绝大多数的#tr[layout]系统,都会记录下一个需要输出到屏幕或纸张上的#tr[glyph]的XY坐标。在输出一个#tr[glyph]之后,这个表示书写位置的坐标就会前移动一段距离。对于水平的字体来说,#tr[layout]系统中的一个变量(常被称为*#tr[cursor]*)会沿着X轴不断前进,#tr[cursor]每次水平前进的距离就是#tr[horizontal advance]。 #figure(caption: [ // a rather beautiful Armenian letter xeh 一个非常美丽的亚美尼亚字母xeh ], placement: none)[#include "dim-1.typ"] <figure:dim-1> // Glyphs in horizontal fonts are assembled along a horizontal baseline, and the horizontal advance tells the layout system how far along the baseline to advance. In this glyph, (a rather beautiful Armenian letter xeh) the horizontal advance is 1838 units. The layout system will draw this glyph by aligning the dot representing the *origin* of the glyph at the current cursor position, inking in all the black parts and then incrementing the X coordinate of the cursor by 1838 units. 水平字体中的#tr[glyph]将会沿着水平的#tr[baseline]排列,#tr[horizontal advance]用于告诉#tr[layout]系统要沿着#tr[baseline]向前走多远。在@figure:dim-1 所示的#tr[glyph]中,#tr[horizontal advance]是1838个单位。#tr[layout]系统在绘制这个#tr[glyph]时,会将#tr[glyph]*原点*和当前#tr[cursor]位置对齐,然后填充所有黑色部分,最后将光标的X坐标向前移动1838个单位。 // Note that the horizontal advance is determined by the em square, not by the outlines. 需要注意,#tr[horizontal advance]的实际长度也是由#tr[em square]的大小决定,和#tr[glyph]#tr[outline]无关。 #figure(placement: none)[#include "dim-2.typ"] // The rectangle containing all the "black parts" of the glyph is sometimes called the *ink rectangle* or the *outline bounding box*. In the Bengali glyph we saw above, the horizontal advance was *smaller* than the outline bounding box, because we wanted to create an overlapping effect. But glyphs in most scripts need a little space around them so the reader can easily distinguish them from the glyphs on either side, so the horizontal advance is usually wider than the outline bounding box. The space between the outline bounding box and the glyph's bounding box is called its sidebearings: 包含#tr[glyph]中所有“黑色部分”的矩形叫做*#tr[ink rectangle]*,或者*#tr[outline]#tr[bounding box]*。在我们之前看过的孟加拉文#tr[glyph]中,因为想要制造一种重叠的效果,会让它的#tr[horizontal advance]比#tr[outline]#tr[bounding box]要*小*,。但大多数文种都需要在#tr[glyph]的周围留有一些空间,来让读者能够更容易地逐个阅读每个#tr[glyph],这时#tr[horizontal advance]就会稍微比#tr[outline]#tr[bounding box]宽一些。在#tr[outline]#tr[bounding box]和整个字形的#tr[bounding box]之间的这些空间叫做#tr[sidebearing]: #figure(placement: none)[#include "dim-4.typ"] // As in the case of Bengali, there will be times where the ink rectangle will poke out of the side of the horizontal advance; in other words, the sidebearings are negative: 对于孟加拉文,有时#tr[ink rectangle]会超出#tr[horizontal advance]的边界。也就是说,#tr[sidebearing]可以是负数: #figure(placement: none)[#include "dim-3.typ"] <figure:dim-3> // In metal type, having bits of metal poking out of the normal boundaries of the type block was called a *kern*. You can see kerns at the top and bottom of this italic letter "f". 在金属排版时代,这种超出活字字身的部分叫做*#tr[kern.origin]*(kern)。你可以从@figure:metal-kern 中看到,在意大利体f的上下部分都存在#tr[kern.origin]。 #figure(caption: [ 金属活字的出格现象 ])[#image("metal-kern.png", width: 50%)] <figure:metal-kern> 但在数字时代,kern这个词被赋予了完全不同的含义……
https://github.com/frectonz/the-pg-book
https://raw.githubusercontent.com/frectonz/the-pg-book/main/book/164.%20altair.html.typ
typst
altair.html What Microsoft Is this the Altair Basic of? February 2015One of the most valuable exercises you can try if you want to understand startups is to look at the most successful companies and explain why they were not as lame as they seemed when they first launched. Because they practically all seemed lame at first. Not just small, lame. Not just the first step up a big mountain. More like the first step into a swamp.A Basic interpreter for the Altair? How could that ever grow into a giant company? People sleeping on airbeds in strangers' apartments? A web site for college students to stalk one another? A wimpy little single-board computer for hobbyists that used a TV as a monitor? A new search engine, when there were already about 10, and they were all trying to de-emphasize search? These ideas didn't just seem small. They seemed wrong. They were the kind of ideas you could not merely ignore, but ridicule.Often the founders themselves didn't know why their ideas were promising. They were attracted to these ideas by instinct, because they were living in the future and they sensed that something was missing. But they could not have put into words exactly how their ugly ducklings were going to grow into big, beautiful swans.Most people's first impulse when they hear about a lame-sounding new startup idea is to make fun of it. Even a lot of people who should know better.When I encounter a startup with a lame-sounding idea, I ask "What Microsoft is this the Altair Basic of?" Now it's a puzzle, and the burden is on me to solve it. Sometimes I can't think of an answer, especially when the idea is a made-up one. But it's remarkable how often there does turn out to be an answer. Often it's one the founders themselves hadn't seen yet.Intriguingly, there are sometimes multiple answers. I talked to a startup a few days ago that could grow into 3 distinct Microsofts. They'd probably vary in size by orders of magnitude. But you can never predict how big a Microsoft is going to be, so in cases like that I encourage founders to follow whichever path is most immediately exciting to them. Their instincts got them this far. Why stop now?
https://github.com/Kasci/LiturgicalBooks
https://raw.githubusercontent.com/Kasci/LiturgicalBooks/master/styleMinea.typ
typst
#import "/style.typ": * #import "/utilsMenlive.typ": * #let mineaVecieren(day, h_st, t) = { let c = counter("day") if "HV" in day { [==== #t("HOSPODI_VOZVACH")] let verse = day.at("HV") c.update(verse.len()) let h = h_st.map(it => make4(it)).slice(-1*(verse.len())) let z = verse.zip(h) let tbl = { z.map(k => ( "", makeGray4(k.at(1)), primText[#c.display("1:"); #c.update(c => c - 1)], k.at(0), ) ) } if "HV_S" in day { tbl.push((primText[S:], day.at("HV_S").at(0))) if "HV_N" in day { tbl.push((primText[I:], day.at("HV_N").at(0))) } else { tbl.push((primText[>I:], make4("!!! "+t("HV_N_NOTE")))) // TODO: encapsulate to makeSec4, but fix error } } if "HV_SN" in day { let sn = day.at("HV_SN") tbl.push((primText[S:I:], sn.at(0))) if (sn.len() > 1) { tbl.push((primText[S:I:], sn.at(1))) } } if "HV_SN2" in day { tbl.push(([!!], make4("А҆́ще и҆́мать самогла́сенъ"))) // FIXME: move to t // TODO: ^^ rework to be more visible let sn = day.at("HV_SN2") tbl.push((primText[S:], sn.at(0))) tbl.push((primText[I:], sn.at(1))) if (sn.len() > 1) { tbl.push((primText[I:], sn.at(2))) } } styleTable4(tbl) } if "S" in day { [==== #t("STICHOVNI")] let (first, ..verse) = day.at("S") c.update(2) let stichy = day.at("S_ST").map(k => make4(k)) let z = verse.zip(stichy) let tbl = { z.map(k => ( [], makeGray4(k.at(1)), primText[#c.display("i:"); #c.step()], k.at(0), )) } c.update(1) tbl.insert(0, (primText[#c.display("i:"); #c.step()], first)) if "S_SN" in day { tbl.push((primText[S:I:], day.at("S_SN").at(0))) } else { tbl.push((primText[S:], day.at("S_S").at(0))) tbl.push((primText[I:], day.at("S_N").at(0))) } styleTable4(tbl) } if "T" in day { [==== #t("TROPAR")] let (tropar, ..last) = day.at("T") let tbl = ( (primText[$#sym.TT$], tropar), ) if last.len() > 0 { tbl.push((primText[$#sym.BB$], last.at(0))) } styleTable4(tbl) } } #let kanon(kanon, t) = { if "H" in kanon { align(center)[#primText[#t("HLAS") #kanon.at("H")]] } for k in range(1,10) { let kk = "P"+str(k) if kk in kanon { [===== #t("PIESEN") #k] let c = counter("kanon-vers") c.update(1) let (irmos, ..verse) = kanon.at(kk) let tbl = { verse.map(xk => ( primText[#c.display("i:"); #c.step()], xk )) } // tbl.insert(0,(primText[$#sym.II _#k$], irmos)) tbl.insert(0,(primText[$#sym.II$], irmos)) if kk+"_K" in kanon { tbl.push((primText[$#sym.KK _#sym.TT$], kanon.at(kk+"_K").at(0))) } styleTable4(tbl) } if k == 3 and "S" in kanon { [===== #t("SIDALEN")] let (sidalen, ..semilast, last) = kanon.at("S") let tbl = () tbl.push((primText[$#sym.SS$], sidalen)) if (semilast.len() > 0) { for s in semilast { tbl.push((primText[S:I:], s)) } } tbl.push((primText[S:I:], last)) styleTable4(tbl) } if k == 6 and "K" in kanon { [===== #t("KONDAK_IKOS")] let kons = kanon.at("K") let idx = range(kons.len()) let z = kons.zip(idx) let i = 0 let tbl = { z.map(xki => { let (xk, i) = xki if i == 0 { (primText[$#sym.KK$], xk) } else { (primText[$#sym.KK _#(i+1)$], xk) } }) } let ikos = kanon.at("I") let idx = range(ikos.len()) let z = ikos.zip(idx) let i = 0 let tbl2 = { z.map(xki => { let (xk, i) = xki if i == 0 { (primText[$#sym.II #sym.KK$], xk) } else { (primText[$#sym.II #sym.KK _#(i+1)$], xk) } }) } for t in tbl2 { tbl.push(t) } styleTable4(tbl) } } } #let mineaUtieren(day, ch_st, t) = { let c = counter("day") if "T" in day { [==== #t("TROPAR")] let (tropar, ..last) = day.at("T") let tbl = ( (primText[$#sym.TT$], tropar), ) tbl.push((primText[$#sym.TT _2$], tropar)) if last.len() > 0 { tbl.push((primText[S:I:], last.at(0))) } styleTable4(tbl) } if "S1" in day { [==== #t("SIDALENY")] for i in range(1,4) { let s = "S"+str(i) if s in day { // TODO: fix [===== Po #(i)-om stichoslovii] c.update(1) let (..verse, last) = day.at(s) let tbl = { verse.map(k => ( primText[#c.display("i:"); #c.step()], k ) ) } tbl.push((primText[S:I:], last)) styleTable4(tbl) } } } if "P" in day { [==== #t("PROKIMEN")] let (prokimen, versv) = day.at("P") [ #set par(first-line-indent: 1em) #styleOne4(prokimen) #primText[#t("STICH"):] #versv.at(3) ] } if "50" in day { [==== #t("50_STICHIRA")] styleOne4(day.at("50").at(0)) } if "K" in day { [==== #t("KANON")] kanon(day.at("K"), t) } if "SV" in day { [==== #t("SVITILEN")] let verse = day.at("SV") c.update(1) let tbl = { verse.map(k => ( primText[#c.display("i:"); #c.step()], k, )) } styleTable4(tbl) } if "CH" in day { [==== #t("CHVALITE")] let verse = day.at("CH") let b = ch_st.map(x=>make4(x)).slice(-1*(verse.len()+2),-2) let z = verse.zip(b) c.update(verse.len()) let tbl = { z.map(k => ( [], makeGray4(k.at(1)), primText[#c.display("1:"); #c.update(c => c - 1)], k.at(0), )) } if "CH_SN" in day { let last = day.at("CH_SN").at(0) tbl.push((primText[S:I:], last)) } else { let semilast = day.at("CH_S").at(0) let last = day.at("CH_N").at(0) tbl.push((primText[S:], semilast)) tbl.push((primText[I:], last)) } styleTable4(tbl) } // TODO: Stichiry stichovni } #let mineaLiturgia(day, b_st, t) = { if "B" in day { [==== #t("BLAZENNA") <X>] let c = counter("day") let (..verse/*, semilast, last*/) = day.at("B") c.update(verse.len()) let b = b_st.map(x=>make4(x)).slice(-1*(verse.len())) let z = verse.zip(b) let tbl = { z.map(k => ( [], makeGray4(k.at(1)), primText[#c.display("1:"); #c.update(c => c - 1)], k.at(0), )) } // tbl.push((primText[S:], semilast)) // tbl.push((primText[I:], last)) styleTable4(tbl) } // if "TKB" in day { // [==== #t("TROPAR_KONDAK") <X>] // let (t,k,b) = day.at("TKB") // let tbl = () // tbl.push((primText[$#sym.TT$], t)) // tbl.push((primText[$#sym.KK$], k)) // tbl.push((primText[$#sym.BB$], b)) // styleTable3(tbl) // } // if "P" in day { // let (prokimen, vers, aleluja, versA) = day.at("P") // [==== #t("PROKIMEN") <X>] // [ // #set par(first-line-indent: 1em) // #prokimen.at(2) // #primText[#t("STICH"):] #vers.at(2) // ] // [===== #t("ALLILUJA") <X>] // [ // #set par(first-line-indent: 1em) // #aleluja.at(2) // #primText[#t("STICH"):] #versA.at(2) // ] // } } #let minea(name, v, h_st, u, ch_st, l, b_st, t) = [ == #t(name) #show: rest => columns(2, rest) === #t("V") #mineaVecieren(v, h_st, t) #if u != none [ === #t("U") #mineaUtieren(u, ch_st, t) ] #if l != none [ === #t("L") #mineaLiturgia(l, b_st, t) ] ]
https://github.com/crd2333/crd2333.github.io
https://raw.githubusercontent.com/crd2333/crd2333.github.io/main/src/docs/Courses/index.typ
typst
#import "/src/components/TypstTemplate/lib.typ": * #show: project.with( title: none, lang: "zh", ) - 很多笔记都是用 typst 写的而不是 md,由于 typst 是个比较新兴的标记语言,对 html 导出做得不够好(或者说官方压根还不支持)。使用社区自制方案以 svg 导出,会有明显的卡顿。 - 同时,目前也没有足够好的像 MkDocs 之于 Markdown 那样的模板。
https://github.com/huyufeifei/grad
https://raw.githubusercontent.com/huyufeifei/grad/master/docs/paper/src/ch6.typ
typst
= 总结 本文详细讲述了如何完全使用安全的Rust语言开发一个设备驱动,并为读者提供了可直接使用的Rust包。通过将这些安全驱动作为隔离域加入到Alien系统中,并对其性能进行全面测试,展示了取代现有不安全驱动的巨大潜力。这项工作不仅为Alien系统的组成部分开发提供了宝贵的实践经验,还为通过语言机制加强操作系统安全的研究提供了重要的探索。 通过本项目,可以看到使用Rust语言在设备驱动开发中的优势和潜力。然而,尽管本项目已经取得了显著的成果,但其仍然没有涵盖设备所有的特性,这为进一步的完善提供了广阔的空间。鼓励在本项目的基础上继续努力,将更多设备的驱动程序重写为安全代码。这将有助于推动设备驱动领域的安全性和可靠性,并为其他研究者和开发者提供宝贵的参考。 值得一提的是,Rust for Linux项目正在逐步将Rust语言引入Linux内核中,以取代传统的C/C++语言。借鉴该项目的经验,可以考虑将使用Rust编写的安全驱动作为Linux内核的可选项加以引入。这样的探索将进一步提升系统的安全性,并促进安全编程实践的普及和应用。 综上所述,本文所介绍的基于安全的Rust语言的设备驱动开发方法为Alien系统的发展和操作系统安全研究的进一步推进做出了重要贡献。相信这一工作将为基于语言机制的操作系统安全领域的研究者和开发者带来新的启示和方向,并为未来的研究和应用提供有力支持。
https://github.com/GYPpro/Java-coures-report
https://raw.githubusercontent.com/GYPpro/Java-coures-report/main/Report/11.typ
typst
#set text(font:("Times New Roman","Source Han Serif SC")) #show raw.where(block: false): box.with( fill: luma(240), inset: (x: 3pt, y: 0pt), outset: (y: 3pt), radius: 2pt, ) // Display block code in a larger block // with more padding. #show raw.where(block: true): block.with( fill: luma(240), inset: 10pt, radius: 4pt, ) #set math.equation(numbering: "(1)") #set text( font:("Times New Roman","Source Han Serif SC"), style:"normal", weight: "regular", size: 13pt, ) #set page( paper:"a4", number-align: right, margin: (x:2.54cm,y:4cm), header: [ #set text( size: 25pt, font: "KaiTi", ) #align( bottom + center, [ #strong[暨南大学本科实验报告专用纸(附页)] ] ) #line(start: (0pt,-5pt),end:(453pt,-5pt)) ] ) #show raw: set text( font: ("consolas", "Source Han Serif SC") ) = 实现一个较为复杂的线性代数计算器 \ #text("*") 实验项目类型:设计性\ #text("*")此表由学生按顺序填写\ #text( font:"KaiTi", size: 15pt )[ 课程名称#underline[#text(" 面向对象程序设计/JAVA语言 ")]成绩评定#underline[#text(" ")]\ 实验项目名称#underline[#text(" 实现一个较为复杂的线性代数计算器 ")]指导老师#underline[#text(" 干晓聪 ")]\ 实验项目编号#underline[#text(" 1 ")]实验项目类型#underline[#text(" 设计性 ")]实验地点#underline[#text(" 数学系机房 ")]\ 学生姓名#underline[#text(" 郭彦培 ")]学号#underline[#text(" 2022101149 ")]\ 学院#underline[#text(" 信息科学技术学院 ")]系#underline[#text(" 数学系 ")]专业#underline[#text(" 信息管理与信息系统 ")]\ 实验时间#underline[#text(" 2023年10月27日上午 ")]#text("~")#underline[#text(" 2023年10月27日中午 ")]\ ] #set heading( numbering: "一、" ) #set par( first-line-indent: 1.8em) = 实验目的 \ #h(1.8em)综合运用面向对象设计工具、字符串、异常处理与对象的抽象等知识,结合线性代数中的算法,基于CAS系统实现一个较为复杂的线性代数计算器。 = 实验环境 \ #h(1.8em)计算机:PC X64 操作系统:Windows 编程语言:Java IDE:Visual Studio Code #pagebreak() = 程序原理 \ #h(1.8em) 实现了以下一些类 #figure( table( align: left+horizon, columns: 3, [myLinearLib],[线性计算主类], [myLinearEntire],[线性空间元素], [ 抽象类:具有线性性质的基础运算 ], [myLinearSpace],[线性空间],[ + 基础运算 + 基 + 计算秩 + 对应矩阵 ], [myMatrix],[矩阵],[ + 基础运算 + 求秩 + 行列式 + 逆 + 转置 + 对角化 ], [myPolynomial],[多项式],[ + 基础运算 + 求值 ], [myRealNum],[实数],[ + 基础运算 ] ) ) 实现的功能:控制台指令如下: 中括号内为需要填入字符串\ 尖括号为可选参数,默认为列表第一个 #figure( table( align: left+horizon, columns: 2, [```shell-unix-generic addMat [columns] [rows] [digit(1,1)] ... [digit(c,r)] ```],[添加一个列数为columns,行数为rows的矩阵], [```shell-unix-generic addPol [dim] [digit 1] ... [digit r] ```],[添加一个阶数为r的多项式], [```shell-unix-generic addLS [rank] [LE name 1] ... [LE name r] ```],[添加一个以`LE 1~r`为基的线性空间], ) ) #figure( table( columns: 2, align: left+horizon, [```shell-unix-generic show <scope :"all" | "Mat" | "Pol" | "LS"> ```],[列出对应的所有元素], [```shell-unix-generic cacuMat [Mat name] <type :"Det" | "Rank" | "inverse" | "transpose" | "Eig"> ```],[计算矩阵的行列式、秩、逆、转置和对角化], [```shell-unix-generic cacuPol [Pol name] [digit] ```],[计算多项式的值], [```shell-unix-generic op [LE name1] <operator :"+" | "-" | "*"> [LE name2] ```],[对线性空间元素进行基础运算], [```shell-unix-generic getUID <type: "date" | "code" | "seq"> [name] ```],[申请对应类型的新UID,并与一个引用名称name绑定], [```shell-unix-generic secUID <type: "date" | "code" | "seq"> [UID] ```],[查找UID对应的引用名称] ) ) = 程序代码 文件:`sis10\myLinearEntire.java`实现了`myLinearEntire`类 ```java package sis10; import java.util.ArrayList; public abstract class myLinearEntire { protected int dim; protected ArrayList<myLinearEntire> coordinate; public myLinearEntire() { this.dim = 0; this.coordinate = new ArrayList<myLinearEntire>(); } public myLinearEntire(int dim, ArrayList<myLinearEntire> coordinate) { this.dim = dim; this.coordinate = new ArrayList<myLinearEntire>(coordinate); } public myLinearEntire(myLinearEntire other) { this.dim = other.dim; this.coordinate = new ArrayList<myLinearEntire>(other.coordinate); } public myLinearEntire(int _dim) { this.dim = _dim; this.coordinate = new ArrayList<myLinearEntire>(); } public int getDim() { return this.dim; } public ArrayList<myLinearEntire> getCoordinate() { return this.coordinate; } abstract public myLinearEntire add(myLinearEntire other) throws Exception; abstract public myLinearEntire multiply(myLinearEntire other) throws Exception; abstract public <N> myLinearEntire multiply(N other) throws Exception; abstract public myLinearEntire negative() throws Exception; abstract public void print() throws Exception; @Override abstract public boolean equals(Object other); @Override abstract public int hashCode(); @Override abstract public String toString(); abstract public double getValue() throws Exception; } ``` 文件:`sis10\myLinearLib.java`实现了`myLinearLib`类 ```java package sis10; import java.util.ArrayList; import java.util.HashMap; public class myLinearLib { private HashMap<String, myLinearEntire> lib; private StringBuffer nowName; private void nextName() { int i = nowName.length() - 1; for(; i >= 0; i--) { if(nowName.charAt(i) != 'z') { nowName.setCharAt(i, (char)(nowName.charAt(i) + 1)); break; } else nowName.setCharAt(i, 'a'); } if(i < 0) nowName.append('a'); } public myLinearLib() { lib = new HashMap<String, myLinearEntire>(); nowName = new StringBuffer("a"); } public myLinearLib(myLinearLib other) { lib = new HashMap<String, myLinearEntire>(other.lib); nowName = new StringBuffer(other.nowName); } public StringBuffer add(myLinearEntire obj) { StringBuffer rt = new StringBuffer(nowName); lib.put(rt.toString(), obj); nextName(); return rt; } public myLinearEntire get(String name) { return lib.get(name); } public void remove(String name) { lib.remove(name); } public void clear() { lib.clear(); } public int size() { return lib.size(); } public String parseCommand(String cmd) throws Exception { String[] cmdList = cmd.split(" "); if(cmdList[0].equals("addMat")) { int col = Integer.parseInt(cmdList[1]); int row = Integer.parseInt(cmdList[2]); myMatrix newMat = new myMatrix(row, col); for(int i = 0; i < row; i++) { for(int j = 0; j < col; j++) { newMat.set(i, j, new myRealNum(Double.parseDouble(cmdList[3 + i * col + j]))); } } return "成功添加矩阵:" + add(newMat).toString(); } else if(cmdList[0].equals("addPol")) { int dim = Integer.parseInt(cmdList[1]); ArrayList<myLinearEntire> newCoordinate = new ArrayList<myLinearEntire>(); for(int i = 0; i < dim; i++) { newCoordinate.add(new myRealNum(Double.parseDouble(cmdList[2 + i]))); } myPolynomial newPol = new myPolynomial(dim, newCoordinate); return "成功添加多项式:" + add(newPol).toString(); } else if(cmdList[0].equals("addLS")) { int rank = Integer.parseInt(cmdList[1]); ArrayList<myLinearEntire> newBasis = new ArrayList<myLinearEntire>(); for(int i = 0; i < rank; i++) { newBasis.add(get(cmdList[2 + i])); } myLinearSpace newLS = new myLinearSpace(rank, newBasis); add(newLS); return nowName.toString(); } else if(cmdList[0].equals("show")) { if(cmdList[1].equals("all")) { return "Mats\n" + parseCommand("show Mat") + "Pols\n" + parseCommand("show Pol") + "LSs\n"+ parseCommand("show LS"); } else if(cmdList[1].equals("Mat")) { String str = ""; for(String key : lib.keySet()) { if(lib.get(key) instanceof myMatrix) { str += key + " : " + lib.get(key).toString() + "\n"; } } return str; } else if(cmdList[1].equals("Pol")) { String str = ""; for(String key : lib.keySet()) { if(lib.get(key) instanceof myPolynomial) { str += key + " : " + lib.get(key).toString() + "\n"; } } return str; } else if(cmdList[1].equals("LS")) { String str = ""; for(String key : lib.keySet()) { if(lib.get(key) instanceof myLinearSpace) { str += key + " : " + lib.get(key).toString() + "\n"; } } return str; } else throw new Exception("非法的show指令。"); } else if(cmdList[0].equals("cacuMat")) { if(get(cmdList[1]) instanceof myMatrix == false) throw new Exception("目标不是矩阵"); myMatrix cacuMatrix = (myMatrix)get(cmdList[1]); if(cmdList[2].equals("Det")) { return String.valueOf(cacuMatrix.det()); } else if(cmdList[2].equals("Rank")) { return String.valueOf(cacuMatrix.getRank()); } else if(cmdList[2].equals("inverse")) { return cacuMatrix.inverse().toString(); } else if(cmdList[2].equals("transpose")) { return cacuMatrix.transpose().toString(); } else if(cmdList[2].equals("Eig")) { return cacuMatrix.Eig().toString(); } else throw new Exception("非法的cacuMat指令。"); } else if(cmdList[0].equals("cacuPol")) { if(get(cmdList[1]) instanceof myPolynomial == false) throw new Exception("目标不是多项式。"); myPolynomial cacuPolynomial = (myPolynomial)get(cmdList[1]); return String.valueOf(cacuPolynomial.cacu(Double.parseDouble(cmdList[2]))); } else if(cmdList[0].equals("op")) { if(cmdList[2].equals("+")) { if(get(cmdList[1]).getClass() != get(cmdList[3]).getClass()) throw new Exception("两个元素类型不同。"); myLinearEntire ans = get(cmdList[1]).add(get(cmdList[3])); return add(ans).toString() + ":\n" + ans.toString(); } else if(cmdList[2].equals("-")) { if(get(cmdList[1]).getClass() != get(cmdList[3]).getClass()) throw new Exception("两个元素类型不同。"); myLinearEntire ans = get(cmdList[1]).add(get(cmdList[3]).multiply(-1)); return add(ans).toString() + ":\n" + ans.toString(); } else if(cmdList[2].equals("*")) { if(get(cmdList[1]).getClass() != get(cmdList[3]).getClass()) throw new Exception("两个元素类型不同。"); myLinearEntire ans = get(cmdList[1]).multiply(get(cmdList[3])); return add(ans).toString() + ":\n" + ans.toString(); } else throw new Exception("非法的op指令。"); } else throw new Exception("非法的指令。"); } } ``` 文件:`sis10\myLinearSpace.java`实现了`myLinearSpace`类 ```java package sis10; import java.util.ArrayList; public class myLinearSpace extends myLinearEntire { private int rank; private ArrayList<myLinearEntire> basis; //↓覆写超类方法 @Override public boolean equals(Object other){ if(other instanceof myLinearSpace){ myLinearSpace mOther = (myLinearSpace)other; if(this.rank != mOther.rank) return false; for(int i = 0; i < this.rank; i++){ if(!this.basis.get(i).equals(mOther.basis.get(i))) return false; } return true; } else return false; } @Override public int hashCode(){ int hash = 0; for(int i = 0; i < this.rank; i++){ hash += this.basis.get(i).hashCode(); } return hash; } @Override public String toString(){ String str = ""; for(int i = 0; i < this.rank; i++){ str += this.basis.get(i).toString() + "\n"; } return str; } //↓构造函数 public myLinearSpace(int rank) { this.rank = rank; this.basis = new ArrayList<myLinearEntire>(); } public myLinearSpace(int rank, ArrayList<myLinearEntire> _basis) { this.rank = rank; this.basis = new ArrayList<myLinearEntire>(_basis); } public myLinearSpace(myLinearSpace other) { this.rank = other.rank; this.basis = new ArrayList<myLinearEntire>(other.basis); } //↓覆写父类方法 public myLinearSpace add(myLinearEntire other) throws Exception { if (other instanceof myLinearSpace) { myLinearSpace mOther = (myLinearSpace) other; if (this.getRank() != mOther.getRank()) { throw new IllegalArgumentException("秩不同的线性空间不能相加。"); } ArrayList<myLinearEntire> newBasis = new ArrayList<myLinearEntire>(); for (int i = 0; i < this.rank; i++) { newBasis.add(this.basis.get(i).add(mOther.basis.get(i))); } return new myLinearSpace(this.rank, newBasis); } else { throw new Exception("非法的线性空间相加。"); } } public myLinearSpace multiply(myLinearEntire other) throws Exception { if (other instanceof myLinearSpace) { myLinearSpace mOther = (myLinearSpace) other; if (this.getRank() != mOther.getRank()) { throw new IllegalArgumentException("秩不同的线性空间不能相乘。"); } ArrayList<myLinearEntire> newBasis = new ArrayList<myLinearEntire>(); for (int i = 0; i < this.rank; i++) { newBasis.add(this.basis.get(i).multiply(mOther.basis.get(i))); } return new myLinearSpace(this.rank, newBasis); } else { throw new Exception("非法的线性空间相乘。"); } } public <N> myLinearSpace multiply(N other) throws Exception { throw new Exception("线性空间的数乘无意义"); } public double getValue() throws Exception { throw new Exception("线性空间的值无意义"); } public myLinearSpace negative() throws Exception { ArrayList<myLinearEntire> newBasis = new ArrayList<myLinearEntire>(); for (int i = 0; i < this.rank; i++) { newBasis.add(this.basis.get(i).negative()); } return new myLinearSpace(this.rank, newBasis); } //↓线性空间特有方法 public int getRank() { return this.rank; } public ArrayList<myLinearEntire> getBasis() { return new ArrayList<myLinearEntire>(basis); } public void print() throws Exception { System.out.println("线性空间的秩为" + this.rank); System.out.println("线性空间的基为"); for (int i = 0; i < this.rank; i++) { System.out.print("第" + i + "个基向量为"); this.basis.get(i).print(); } } } ``` 文件:`sis10\myMatrix.java`实现了`myMatrix.java`类 ```java package sis10; import java.util.ArrayList; public class myMatrix extends myLinearEntire{ private int row; private int col; private ArrayList<ArrayList<myLinearEntire>> matrix; //↓覆写超类方法 @Override public boolean equals(Object other){ if(other instanceof myMatrix){ myMatrix mOther = (myMatrix)other; if(this.row != mOther.row || this.col != mOther.col) return false; for(int i = 0; i < this.row; i++){ for(int j = 0; j < this.col; j++){ if(!this.matrix.get(i).get(j).equals(mOther.matrix.get(i).get(j))) return false; } } return true; } else return false; } @Override public int hashCode(){ int hash = 0; for(int i = 0; i < this.row; i++){ for(int j = 0; j < this.col; j++){ hash += this.matrix.get(i).get(j).hashCode(); } } return hash; } @Override public String toString(){ String str = ""; for(int i = 0; i < this.row; i++){ for(int j = 0; j < this.col; j++){ str += this.matrix.get(i).get(j).toString() + " "; } if(i != this.row-1)str += "\n"; } return str; } //↓构造函数 public myMatrix(int row, int col) { this.row = row; this.col = col; this.matrix = new ArrayList<ArrayList<myLinearEntire>>(); for (int i = 0; i < row; i++) { ArrayList<myLinearEntire> newRow = new ArrayList<myLinearEntire>(); for (int j = 0; j < col; j++) { newRow.add(new myRealNum(0)); } this.matrix.add(newRow); } } public myMatrix(int row, int col, ArrayList<ArrayList<myLinearEntire>> matrix) { this.row = row; this.col = col; this.matrix = new ArrayList<ArrayList<myLinearEntire>>(matrix); } public myMatrix(myMatrix other) { this.row = other.row; this.col = other.col; this.matrix = new ArrayList<ArrayList<myLinearEntire>>(other.matrix); } //↓ 覆写父类方法 public myMatrix add(myLinearEntire other) throws Exception { if (other instanceof myMatrix) { myMatrix mOther = (myMatrix) other; if (this.getRow() != mOther.getRow() || this.getCol() != mOther.getCol()) { throw new IllegalArgumentException("行列不同的矩阵不能相加。"); } ArrayList<ArrayList<myLinearEntire>> newMatrix = new ArrayList<ArrayList<myLinearEntire>>(); for (int i = 0; i < this.row; i++) { ArrayList<myLinearEntire> newRow = new ArrayList<myLinearEntire>(); for (int j = 0; j < this.col; j++) { newRow.add(this.matrix.get(i).get(j).add(mOther.matrix.get(i).get(j))); } newMatrix.add(newRow); } return new myMatrix(this.row, this.col, newMatrix); } else { throw new Exception("非法的矩阵相加。"); } } public myMatrix multiply(myLinearEntire other) throws Exception { if (other instanceof myMatrix) { myMatrix mOther = (myMatrix) other; if (this.getCol() != mOther.getRow()) { throw new IllegalArgumentException("行列不匹配的矩阵不能相乘。"); } ArrayList<ArrayList<myLinearEntire>> newMatrix = new ArrayList<ArrayList<myLinearEntire>>(); for (int i = 0; i < this.row; i++) { ArrayList<myLinearEntire> newRow = new ArrayList<myLinearEntire>(); for (int j = 0; j < mOther.col; j++) { myLinearEntire sum = new myRealNum(0); for (int k = 0; k < this.col; k++) { sum = sum.add(this.matrix.get(i).get(k).multiply(mOther.matrix.get(k).get(j))); } newRow.add(sum); } newMatrix.add(newRow); } return new myMatrix(this.row, mOther.col, newMatrix); } else { throw new Exception("非法的矩阵相乘。"); } } public <N> myMatrix multiply(N other) throws Exception { if (other instanceof myRealNum) { myRealNum rOther = (myRealNum) other; ArrayList<ArrayList<myLinearEntire>> newMatrix = new ArrayList<ArrayList<myLinearEntire>>(); for (int i = 0; i < this.row; i++) { ArrayList<myLinearEntire> newRow = new ArrayList<myLinearEntire>(); for (int j = 0; j < this.col; j++) { newRow.add(this.matrix.get(i).get(j).multiply(rOther)); } newMatrix.add(newRow); } return new myMatrix(this.row, this.col, newMatrix); } else { throw new Exception("非法的矩阵数乘。"); } } public double getValue() { try { return this.det(); } catch (Exception e) { e.printStackTrace(); return 0; } } public void print() throws Exception { for (int i = 0; i < this.row; i++) { for (int j = 0; j < this.col - 1; j++) { this.matrix.get(i).get(j).print(); System.out.print(" "); } this.matrix.get(i).get(this.col - 1).print(); System.out.println(); } } public myLinearEntire negative() throws Exception { ArrayList<ArrayList<myLinearEntire>> newMatrix = new ArrayList<ArrayList<myLinearEntire>>(); for (int i = 0; i < this.row; i++) { ArrayList<myLinearEntire> newRow = new ArrayList<myLinearEntire>(); for (int j = 0; j < this.col; j++) { newRow.add(this.matrix.get(i).get(j).negative()); } newMatrix.add(newRow); } return new myMatrix(this.row, this.col, newMatrix); } //↓矩阵特有方法 public int getRow() { return this.row; } public int getCol() { return this.col; } public double det() throws Exception //计算行列式 { if (this.row != this.col) { throw new Exception("非方阵无法求行列式。"); } if (this.row == 1) { return ((myRealNum) this.matrix.get(0).get(0)).getNum(); } double ans = 0; for (int i = 0; i < this.row; i++) { myMatrix subMatrix = new myMatrix(this.row - 1, this.col - 1); for (int j = 1; j < this.row; j++) { for (int k = 0; k < this.col; k++) { if (k < i) { subMatrix.matrix.get(j - 1).add(this.matrix.get(j).get(k)); } else if (k > i) { subMatrix.matrix.get(j - 1).add(this.matrix.get(j).get(k)); } } } ans += ((myRealNum) this.matrix.get(0).get(i)).getNum() * subMatrix.det() * (int) Math.pow(-1, i); } return ans; } public int getRank() throws Exception //计算秩 { if (this.row == 1) { for (int i = 0; i < this.col; i++) { if (((myRealNum) this.matrix.get(0).get(i)).getNum() != 0) { return 1; } } return 0; } int ans = 0; for (int i = 0; i < this.col; i++) { myMatrix subMatrix = new myMatrix(this.row - 1, this.col - 1); for (int j = 1; j < this.row; j++) { for (int k = 0; k < this.col; k++) { if (k < i) { subMatrix.matrix.get(j - 1).add(this.matrix.get(j).get(k)); } else if (k > i) { subMatrix.matrix.get(j - 1).add(this.matrix.get(j).get(k)); } } } if (((myRealNum) this.matrix.get(0).get(i)).getNum() != 0) { ans += subMatrix.getRank(); } } return ans; } public myMatrix inverse() throws Exception //计算逆矩阵 { if (this.row != this.col) { throw new Exception("非方阵无法求逆。"); } if (this.det() == 0) { throw new Exception("行列式为0,无法求逆。"); } myMatrix ans = new myMatrix(this.row, this.col); for (int i = 0; i < this.row; i++) { for (int j = 0; j < this.col; j++) { myMatrix subMatrix = new myMatrix(this.row - 1, this.col - 1); for (int k = 0; k < this.row; k++) { for (int l = 0; l < this.col; l++) { if (k < i && l < j) { subMatrix.matrix.get(k).add(this.matrix.get(k).get(l)); } else if (k < i && l > j) { subMatrix.matrix.get(k).add(this.matrix.get(k).get(l)); } else if (k > i && l < j) { subMatrix.matrix.get(k - 1).add(this.matrix.get(k).get(l)); } else if (k > i && l > j) { subMatrix.matrix.get(k - 1).add(this.matrix.get(k).get(l)); } } } ans.matrix.get(i).add(new myRealNum(subMatrix.det() * (int) Math.pow(-1, i + j))); } } ans = ans.transpose(); ans = ans.multiply(new myRealNum(1 / this.det())); return ans; } public myMatrix transpose() throws Exception //计算转置矩阵 { myMatrix ans = new myMatrix(this.col, this.row); for (int i = 0; i < this.col; i++) { for (int j = 0; j < this.row; j++) { ans.matrix.get(i).add(this.matrix.get(j).get(i)); } } return ans; } public myMatrix Eig() throws Exception//进行对角化 { if (this.row != this.col) { throw new Exception("非方阵无法求特征值。"); } myMatrix ans = new myMatrix(this.row, this.col); for (int i = 0; i < this.row; i++) { ans.matrix.get(i).add(this.matrix.get(i).get(i)); } return ans; } public void set(int i, int j, myRealNum myRealNum) //重设矩阵某个元素 { this.matrix.get(i).set(j, myRealNum); } } ``` 文件:`sis10\myPolynomial.java`实现了`myPolynomial`类 ```java package sis10; import java.util.ArrayList; public class myPolynomial extends myLinearEntire{ int xValue = 1; //↓覆写超类方法 @Override public boolean equals(Object other){ if(other instanceof myPolynomial){ myPolynomial mOther = (myPolynomial)other; if(this.dim != mOther.dim) return false; for(int i = 0; i < this.dim; i++){ if(!this.coordinate.get(i).equals(mOther.coordinate.get(i))) return false; } return true; } else return false; } @Override public int hashCode(){ int hash = 0; for(int i = 0; i < this.dim; i++){ hash += this.coordinate.get(i).hashCode(); } return hash; } @Override public String toString(){ String str = ""; for(int i = 0; i < this.dim; i++){ str += this.coordinate.get(i).toString() + "\n"; } return str; } //↓构造函数 public myPolynomial() { super(); } public myPolynomial(int _dim, ArrayList<myLinearEntire> _coordinate) { super(_dim, _coordinate); } public myPolynomial(myPolynomial other) { super(other); } public myPolynomial(int _dim) { super(_dim); for(int i = 0;i < _dim;i ++) coordinate.add(new myRealNum(0)); } //↓覆写父类方法 public myPolynomial add(myLinearEntire other) throws Exception { if (other instanceof myPolynomial) { myPolynomial mOther = (myPolynomial) other; ArrayList<myLinearEntire> newCoordinate = new ArrayList<myLinearEntire>(); for (int i = 0; i < Math.min(this.getDim(),other.getDim()); i++) { newCoordinate.add(this.getCoordinate().get(i).add(mOther.getCoordinate().get(i))); } for (int i = Math.min(this.getDim(),other.getDim()); i < Math.max(this.getDim(),other.getDim()); i++) { if (this.getDim() > other.getDim()) { newCoordinate.add(this.getCoordinate().get(i)); } else { newCoordinate.add(mOther.getCoordinate().get(i)); } } return new myPolynomial(this.getDim(), newCoordinate); } else { throw new Exception("非法的多项式相加。"); } } public myPolynomial multiply(myLinearEntire other) throws Exception { if (other instanceof myPolynomial) { myPolynomial mOther = (myPolynomial) other; ArrayList<myLinearEntire> newCoordinate = new ArrayList<myLinearEntire>(); int aimDim = this.getDim() + mOther.getDim() - 1; for (int i = 0; i < aimDim; i++) { newCoordinate.add(new myRealNum(0)); } for (int i = 0; i < this.getDim(); i++) { for (int j = 0; j < mOther.getDim(); j++) { newCoordinate.set(i + j, newCoordinate.get(i + j).add(this.getCoordinate().get(i).multiply(mOther.getCoordinate().get(j)))); } } return new myPolynomial(aimDim, newCoordinate); } else { throw new Exception("非法的多项式相乘。"); } } public <N> myPolynomial multiply(N other) throws Exception { ArrayList<myLinearEntire> newCoordinate = new ArrayList<myLinearEntire>(); for (int i = 0; i < this.getDim(); i++) { newCoordinate.add(this.getCoordinate().get(i).multiply(other)); } return new myPolynomial(this.getDim(), newCoordinate); } public void print() throws Exception { for (int i = 0; i < this.getDim(); i++) { this.getCoordinate().get(i).print(); } } public double getValue() { try { return this.cacu(1); } catch (Exception e) { e.printStackTrace(); return 0; } } public myLinearEntire negative() throws Exception { ArrayList<myLinearEntire> newCoordinate = new ArrayList<myLinearEntire>(); for (int i = 0; i < this.getDim(); i++) { newCoordinate.add(this.getCoordinate().get(i).negative()); } return new myPolynomial(this.getDim(), newCoordinate); } //↓多项式特有方法 public double cacu(double x) throws Exception { //给定x的值计算多项式的值 double result = 0; for (int i = 0; i < this.getDim(); i++) { result += this.getCoordinate().get(i).getValue(); } return result; } public int getDim() { return super.dim; } public ArrayList<myLinearEntire> getCoordinate() { return super.coordinate; } public void set(int index, myLinearEntire value) //设置多项式的某一项 { super.coordinate.set(index, value); } } ``` 文件:`sis10\myRealNum.java`实现了`myRealNum`类 ```java package sis10; public class myRealNum extends myLinearEntire{ private double value; //↓覆写超类方法 @Override public boolean equals(Object other){ if(other instanceof myRealNum){ myRealNum mOther = (myRealNum)other; if(this.value != mOther.value) return false; else return true; } else return false; } @Override public int hashCode(){ return (int)this.value; } @Override public String toString(){ return String.valueOf(this.value); } //↓构造函数 public myRealNum(double value) { this.value = value; } public myRealNum(myRealNum other) { this.value = other.value; } //↓覆写父类方法 public myLinearEntire add(myLinearEntire other) throws Exception { if (other instanceof myRealNum) { myRealNum mOther = (myRealNum) other; return new myRealNum(this.value + mOther.value); } else { throw new Exception("非法的实数相加。"); } } public <N> myLinearEntire multiply(N other) throws Exception { return new myRealNum(value * (double) other); } public myLinearEntire multiply(myLinearEntire other) throws Exception { if (other instanceof myRealNum) { myRealNum mOther = (myRealNum) other; return new myRealNum(this.value * mOther.value); } else { throw new Exception("非法的实数相乘。"); } } public void print() throws Exception { System.out.println(this.value); } public double getValue() { return this.value; } public double getNum() { return this.value; } public myLinearEntire negative() throws Exception { return new myRealNum(-this.value); } } ``` 文件:`sis10\Test.java`实现了`Test`类,作为入口与测试用 ```java package sis10; import java.util.Scanner; public class Test { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { myLinearLib lib = new myLinearLib(); for(;;) { String s = sc.nextLine(); try { System.out.println(lib.parseCommand(s)); } catch (Exception e) { e.printStackTrace(); } } } } } ``` = 出现的问题、原因与解决方法 \ #h(1.8em) 由于代码量较大,且没有开源项目可参考,编码过程中遇到了不少阻碍。 其中最大的困难是难以将所有具有线性性的元素归入统一的框架内。好在JAVA提供了抽象类这一工具。于是我构造了一个抽象类`myLinearEntire`,所有的其他类型具有线性性的元素都可以继承此抽象类,并且需要实现抽象类所规定的抽象成员方法。 这样做,可以很方便地统一各个线性元素之间、不同元素之间的运算、存储、管理等操作,并且为程序提供了良好的可扩展性。 在不同的类之间,我使用了保护性传值和深拷贝等技巧,保证了所有成员变量的安全性,同时有完备的异常处理,程序可以以较高的鲁棒性运行。 有一个很小的问题,虽然是实现此系统过程中无数小问题中的一个,但我认为值得关注。在实现矩阵间运算时,我需要判断传入的`myLinearEntire`类型的对象是否为矩阵。经实验,嵌套`instanceof`并不能实现此功能。查阅资料得在`Objec`超类中实现了`getClass()`方法,可以运行时获取对象的类型。 在后续的编码过程中,我加深了对此方法的理解,意识到这个方法对JAVA的面向对象系统具有重要意义,于是查阅了资料,研究了此方法的原理及其对JAVA面向对象系统的意义,总结如下: + Object.getClass() 方法的作用:\ 获取对象的运行时类: 返回一个Class对象,该对象包含了与调用该方法的对象的实际类相关的信息。\ 支持运行时类型检查: 可以使用getClass()方法进行运行时的类型检查。例如,可以在运行时确定一个对象是否属于特定的类或接口。 + 原理:\ Object.getClass()方法的原理是基于Java的反射机制。反射是在运行时动态获取类的信息的机制。当调用getClass()方法时,会返回一个Class对象,该对象包含有关类的信息,如类的名称、字段、方法等。\ 在Java中,每个类都有一个对应的Class对象,这个对象是在加载类时由Java虚拟机创建的。因此,getClass()方法实际上是返回对象所属类的Class对象的引用。 + 对Java面向对象体系的贡献:\ 运行时类型信息(RTTI): Object.getClass()方法提供了一种在运行时获取对象类型信息的机制,使得可以在程序运行时动态地了解和操作对象的类型。\ 动态创建对象: 反射机制通过Class对象可以在运行时动态创建类的实例,这对一些框架、库和工具的开发是非常有用的。\ 框架和工具的实现: 反射机制为许多框架和工具提供了基础,例如,通过反射可以在运行时动态地加载和管理类,实现插件系统,以及处理配置文件中的类名等。\ 动态代理: 反射机制支持动态代理的实现,允许在运行时生成代理类来实现特定接口或继承特定类的代理对象。 = 测试数据与运行结果 #figure( table( align: left + horizon, columns: 3, [*输入*],[*输出*],[*解释*], [`addMat 2 2 1 2 3 4 addMat 2 2 1 0 0 1 addMat 2 3 1 1 2 3 4 5 6 addMat 2 3 1 0 0 0 1 2 3`],[`成功添加矩阵:a 成功添加矩阵:b 成功添加矩阵:c 成功添加矩阵:d`],[添加矩阵], [`addPol 2 1 2 addPol 2 1 0`],[`成功添加多项式:e 成功添加多项式:f`],[添加多项式], [`addLS 2 e f`],[`h`],[添加线性空间], [`show all`],[`Mats a : 1.0 2.0 3.0 4.0 b : 1.0 0.0 0.0 1.0 c : 1.0 1.0 2.0 3.0 4.0 5.0 d : 1.0 0.0 0.0 0.0 1.0 2.0 Pols e : 1.0·x^ 0+ 2.0·x^ 1 f : 1.0·x^ 0+ 0.0·x^ 1 LSs g : 1.0·x^ 0+ 2.0·x^ 1 1.0·x^ 0+ 0.0·x^ 1`],[显示内存中\ 储存了的所有\ 元素], [],[],[续表] )) #figure( table( align: left + horizon, columns: 3, [*输入*],[*输出*],[*解释*], [`op a + b`],[`i: 2.0 2.0 3.0 5.0`],[计算矩阵a+b\ 输出结果并记为i], [`op a * b`],[`j: 1.0 2.0 3.0 4.0`],[计算矩阵a \* b\ 输出结果并记为j], [`op c * d`],[`行列不匹配的矩阵不能相乘。`],[], [`op c * a`],[`k: 4.0 6.0 11.0 16.0 19.0 28.0`],[计算矩阵c \* a \ 输出结果并记为k], [`cacuMat a Rank`],[`2`],[a的秩为2], [`cacuMat d Rank`],[`1`],[b的秩为2], [`cacuMat c Det`],[`非方阵无法求行列式。`],[], [`cacuMat a Det`],[`-2.0`],[矩阵a的行列式为-2], [`cacuPol e 2`],[`3.0`],[将$x = 2$代入多项式e], [`op e * f`],[`l: 1.0·x^ 0+ 2.0·x^ 1+ 0.0·x^ 2`],[计算多项式e \* f\ 输出结果并记为l], [`cacuPol l 1`],[`3.0`],[将$x = 1$代入多项式l], [`cacuPol l 3`],[`7.0`],[将$x = 3$代入多项式l], [`addMat 3 3 2 1 -1 1 1 1 1 2 3`],[`成功添加矩阵:m`],[], [`cacuMat m inverse`],[`n: -1.0 5.0 -2.0 2.0 -7.0 3.0 -1.0 3.0 -1.0`],[计算矩阵m的逆], [`addMat 3 3 2 1 -1 1 2 3 1 2 3`],[`成功添加矩阵:o`],[], [`cacuMat o inverse`],[`行列式为0,无法求逆。`],[], [`cacuMat o Rank`],[`2`],[`果然不满秩`] ) )
https://github.com/jgm/typst-hs
https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/if-04.typ
typst
Other
// Condition must be boolean. // If it isn't, neither branch is evaluated. // Error: 5-14 expected boolean, found string #if "a" + "b" { nope } else { nope }
https://github.com/jassielof/typst-templates
https://raw.githubusercontent.com/jassielof/typst-templates/main/apa7/utils/orcid.typ
typst
MIT License
#let include-orcid(author, orcid) = { if orcid != none [ #if orcid.contains(regex("^\d{4}-\d{4}-\d{4}-\d{4}$")) == false { panic("ORCID format must be XXXX-XXXX-XXXX-XXXX: ", orcid) } else if type(orcid) != str { panic("ORCID must be of type string: ", type(orcid)) } #author #box(height: 1em, image("../assets/img/ORCID_iD.svg.png", width: 2.5%),) #link("https://orcid.org/" + orcid) ] else { author } }
https://github.com/sitandr/typst-examples-book
https://raw.githubusercontent.com/sitandr/typst-examples-book/main/src/typstonomicon/inline_with.md
markdown
MIT License
# Horizontally align something with something ```typ // author: tabiasgeehuman #let inline-with(select, content) = context { let target = query( selector(select) ).last().location().position().x let current = here().position().x box(inset: (x: target - current + 0.3em), content) } #let inline-label(name) = [#line(length: 0%) #name] #inline-with(selector(<start-c>))[= Common values] #align(left, box[$ #inline-label(<start-c>) "Circles"(0) =& 0 \ lim_(x -> 1) "Circles"(0) =& 0 $]) ```
https://github.com/khicken/CSDS310
https://raw.githubusercontent.com/khicken/CSDS310/main/Assignment%202/Assignment%202%20v2.typ
typst
#import "@preview/lovelace:0.3.0": pseudocode-list #set enum(numbering: "ai)") #set align(right) <NAME> \ 9/21/24 #set align(center) = CSDS 310 Assignment 2 (rev) #set align(left) _Note: Arrays are zero-indexed._ == Problem 3 + With $T(n)$ in Master Theorem form, $T(n) = a T(n slash b) + f(n)$, given $a = b$ and $b = a$. \ \ We have $a > b$ by reversing our given statement, meaning that $log_b a > 1$. Raising both sides to the $n$, we have $n^(log_b a) > n^1$. This means that $n^(log_b a)$ is an upper bound of $f(n)$, which means $f(n) = O(n^(log_b a))$, which is Case 1. Thus, $T(n) = n^(log_b a)$. \ \ + With $T(n)$ in Master Theorem form, $T(n) = a T(n slash b) + f(n)$, given $a = a^2$ and $b = a$. We have $ log_b a = (log a) / (log b) = (log a) / (log (a^2)) = (log a) / (2 log a) = 1/2 $ Given that $f(n)=Theta(n^2)$, comparing it to $n^(log_b a) = n^(1/2)$, $f(n)$ grows much faster than $n^(log_b a)$. We have $f(n) = Omega(n^(log_b a))$, which is Case 3. \ \ Thus, $T(n) = O(n^2)$. \ \ + With $T(n)$ in Master Theorem form, $T(n) = a T(n slash b) + f(n)$, given $a = 1$ and $b=lambda$. We have $log_b a = log_lambda (1) = 0$. This means that $n^(log_b a) = n^(0) = 1$, which is constant. We have $f(n)=n^lambda$, which grows more than a constant function. In other words, $f(n)=Omega(n^(log_b a))$, which is Case 3. Thus, $T(n) = O(n^lambda)$. \ \ == Problem 4 === Pseudocode: #pseudocode-list[ + *procedure* MERGE(A, n, k): + *if* $k$ == 1: + *return* A + A' ← Array of $ceil(k/2)$ elements + *for* $0 <= i < floor(k / 2)$: + A'[i] ← SUBMERGE(A[2i], A[2i+1]) + *if* $k$ is odd: + A'[$k / 2$] ← A[$k-1$] \/\/ Put last element in A' + *return* MERGE(A', n, $ceil(k/2)$) ] The merging of two subarrays, cleverly named: #pseudocode-list[ + *procedure* SUBMERGE(A, B): + i ← 0 + j ← 0 + C ← Array of $n_A + n_B$ elements + *while* i + j < len(A) + len(B): + *if* i == len(A): + C[i+j] ← B[j] + j ← j + 1 + *else if* j == len(B) or A[i] < B[j]: + C[i+j] ← A[i] + i ← i + 1 + *else*: + C[i+j] ← B[j] + j ← j + 1 + *endwhile* + *return* C ] === Proof: `SUBMERGE` procedure proof by loop invariance: - *Loop invariant:* At the start of each iteration, $C$ is an array sorted in nondecreasing order, such that $C[0...i+j-1]$ contains the same elements from subarrays $A[0...i-1]$ and $B[0...j-1]$. - *Initialization:*: Before the first iteration, $i = 0$ and $j = 0$. We have $i + j = 0$. By the loop invariant, $C[0...-1]$ is a null (empty) array, and so as $A[0...-1]$ and $B[0...-1]$. Trivially, $C$ holds the same elements of subarrays $A$ and $B$, thus the loop invariant holds at this step. - *Maintenance*: (1) If at the start of an iteration $i >=$ the elements in $A$, then increment $j$ by one and append $B[j]$ to $C$. Likewise, (2) if $j >=$ the elements in $B$, then increment $i$ by one and append $A[i]$ to $C$. These cases occur when we have iterated through all the elements in either subarray. (3) If $A[i] < B[j]$, then the smaller element, append $A[i]$ to $C$ and increment $i$ by one. (4) Else, when $A[i] >= B[j]$, append $B[j]$ to $C$ and increment $j$ by one. \ \ All cases (1-4) result in incrementing either $i$ or $j$ by one, with each case appending the smaller element to $C[0...(i+j+1)-1]$ from either $A[0...(i+1)-1]$ or $B[0...(j+1)-1]$, maintaining the loop invariant. - *Termination*: The loop terminates when $i + j$ meet the total number of elements from $A$ and $B$. Since the loop invariant held over all elements of $A$ and $B$, $C$ is an array sorted in nondecreasing order, containing each element from $A$ and $B$ once. `MERGE` procedure proof by induction: - *Base case*: At $k=1$, trivially array $A$ is fully merged. - *Inductive step*: By induction, it can be assumed that for $k > 1$, we can continue to merge subarrays. We create an output array $A'$ that stores $ceil(k/2)$ elements. Trivially, the for loop merges two subarrays $A[2i]$ and $A[2i+1]$ into one (proven that `SUBMERGE` is correct), storing it in $A'[i]$. The loop terminates at the end of $floor(k/2)$, adding the leftover odd element when necessary. === Runtime analysis: The `SUBMERGE` procedure contains a while loop that makes $n_A + n_B$ comparisons, with the number of elements of $A$ and $B$ being $n_A$ and $n_B$ respectively. In one iteration of the `MERGE` procedure, the `SUBMERGE` procedure is called $k/2$ times in the for loop of line (5), iterating over two subarrays each iteration. Hence, the worst-case runtime for one iteration of `MERGE` is $O(k/2 * 2 * n/k) = O(n)$. #image("2.png") Drawing a recursion tree, we will `MERGE` about $O(log k)$ times. Thus, $T(n) = O(n) * O(log k) = O(n log k)$.
https://github.com/Enayaaa/typst-boxproof
https://raw.githubusercontent.com/Enayaaa/typst-boxproof/main/src/lib.typ
typst
MIT License
#let enumerate(arr) = range(arr.len()).zip(arr) #let tail(arr) = { let len = arr.len() enumerate(arr).filter(x => x.at(0) != 0).map(x => x.at(1)) } #let width(body, styles) = { if type(body) == content { measure(body, styles).width } else if type(body) == array { body.map(x => width(x, styles)).sum() } else { measure([#body], styles).width } } #let height(body, styles) = { if type(body) == content { measure(body, styles).height } else if type(body) == array { body.map(x => height(x, styles)).sum() } else { measure([#body], styles).height } } #let ast_to_content_list(styles, maxlen, ast, neg, depth) = { // assert(type(ast) == array) if type(ast) == array { let contents = ast.map(b=>[#b]) grid( columns: 2, gutter: maxlen - width(ast.at(0), styles) + 3em, ..contents ) } else if type(ast) == dictionary { if ast.type == "box" { let nBoxes(arr) = {arr.filter(x => type(x) == dictionary).filter(x => x.type == "box").len()} let res = ast.children.map(x => { if type(x) == dictionary { ast_to_content_list(styles, maxlen - ast.indent, x, 0.6em * nBoxes(x.children) + neg*depth, depth+1) } else { ast_to_content_list(styles, maxlen - ast.indent, x, 0pt, depth+1) } }).flatten() let t = table(columns: 1, inset: 0.3em, ..res) let size = measure(t, styles) enumerate(res).map(x => { let (i,y) = x if i == 0 { let boxed(..more) = box( y, width: size.width + ast.indent, height: size.height + 0.6em - neg, inset: (y: 0pt, x: ast.indent), outset: (y: 3pt), ..more ) place( if ast.stroke != auto { boxed(stroke: ast.stroke) } else { boxed() } ) } else { box( y, inset: (x: ast.indent) ) } }) } } } #let maxlen(..bits, styles) = { let vals = bits.pos().map(b => { // assert(type(b) == array or type(b) == dictionary, message: "Array bits in fitch, got " + type(b)) if type(b) == dictionary { if b.type == "box" { b.indent + maxlen(..b.children, styles) } } else if type(b) == array { width(b.at(0), styles) } else { assert(false, message: "Checking maxwidth of unknown type " + type(b)) } }).flatten() calc.max(..vals) } #let helper_fitch(..bits, styles) = { let maxlen = maxlen(..bits, styles) let content = bits.pos().map(b => ast_to_content_list(styles, maxlen, b, 0pt, 1)).flatten() let table_bits = () let lineno = 1 while lineno <= content.len() { table_bits.push([#lineno]) table_bits.push(content.at(lineno - 1)) lineno = lineno + 1 } table( columns: (18pt, 100%), // line spacing inset: 0.3em, stroke: none, ..table_bits ) } #let fitch(..bits) = { style(styles => { helper_fitch( ..bits, styles ) }) } #let line(..bits) = { // let arr = bits.pos() // assert(arr.len() == 2) ($#bits.pos().first()$,) tail(bits.pos()).map(x => $#x$) } #let proof = fitch #let con = [hello world] #let b = table(con, stroke: 1pt + black, inset: 0.3em) #con \ #style(styles => measure(con, styles)) #b \ #style(styles => measure(b, styles)) // stroke: auto - default behaviour of stroke for box #let box(..bits, indent: 10pt, stroke: 0.7pt + black) = { ( type: "box", indent: indent, stroke: stroke, children: bits.pos() ) } #proof( box( line($forall x. forall y. P(x, y)$, [prem.]), box( stroke: red, line($x_0$, [fresh]), box( stroke: red, line($x_0$, [fresh]), line($forall x. forall y. P(x, y)$, [prem. what is this bro!]), line($x_0$, [fresh]), line($forall x. forall y. P(x, y)$, [prem. what is this bro!]), line($forall x. forall y. P(x, y)$, [prem.]), line($forall x. forall y. P(x, y)$, [prem.]), ), line($forall x. forall y. P(x, y)$, [prem.]), line($forall x. forall y. P(x, y)$, [prem.]), ), line($forall x. forall y. P(x, y)$, [prem.]), ), line($forall x. forall y. P(x, y)$, [prem.]), ), line($forall x. forall y. P(x, y)$, [prem.]), ) // #proof( // line($p or q$, [LEM]), // box( // ($p and q$, [prem.]), // ($p -> q$, [prem.]), // ($forall x. (q and p <-> "hello world")$, [prem.]), // ($forall x. (q and p <-> "hello world")$, [prem.]), // ($forall x. (q and p <-> exists y. (P(y) and Q(x)))$, $forall_i 1, 2 "with" phi.alt = 2psi$), // ($1 + 2$,2), // ($forall x. (q and p <-> exists y. (P(y) and Q(x)))$, $forall_i 1, 2 "with" phi.alt = 2psi$), // ($forall x. (q and p <-> exists y. (P(y) and Q(x)))$, $forall_i 1, 2 "with" phi.alt = 2psi$), // box( // ($p or q$, [LEM]), // box(($p or q$, [LEM])), // box(($p$, [LEM])), // box(($p$, [LEM])), // box(($p$, [LEM])), // box(($p$, [LEM])), // box(($p$, [LEM])), // box(($p$, [LEM])), // box(($p$, [LEM])), // box(($p$, [LEM])), // ($p or q$, [LEM]), // ($forall x. (q and p <-> exists y. (P(y) and Q(x)))$, $forall_i 1, 2 "with" phi.alt = 2psi$), // ($p or q$, [LEM]), // ($p or q$, [LEM]), // ($p or q$, [LEM]), // ($p or q$, [LEM]), // ) // ), // line($p or q$, [LEM]), // )
https://github.com/typst-community/guidelines
https://raw.githubusercontent.com/typst-community/guidelines/main/src/chapters/style/naming.typ
typst
Creative Commons Attribution Share Alike 4.0 International
#import "/src/util.typ": * #import mantys: * = Naming Identifiers use `kebab-case`, i.e. lowercase words separated by hyphens. Identifiers should be concise, but clear. Avoid long name with many hyphens for public APIs. Abbreviations and uncommon names should be avoided or at least clarified when use din public APIs. #do-dont[ ```typc let name let short-name ``` ][ ```typc let shortname // missing hyphen let avn // uncommon abbreviation let unnecessarily-long-name // longer than needed ``` ]
https://github.com/fufexan/cv
https://raw.githubusercontent.com/fufexan/cv/typst/modules_ro/certificates.typ
typst
#import "../src/template.typ": * #cvSection("Diplome") #cvHonor( date: [2016], title: [Premiul 1, etapa județeană], issuer: [Olimpiada de Engleză], ) #cvHonor( date: [2017-2019], title: [Mențiuni], issuer: [Olimpiada de Engleză], ) #cvHonor( date: [2020], title: [Premiul 2, etapa județeană], issuer: [Olimpiada de Engleză], ) #cvHonor( date: [2017 - 2018, 2020], title: [Participare], issuer: [Olimpiada de Informatică], ) #cvHonor( date: [2022], title: [#link("https://drive.google.com/file/d/1-J-29m5L9CdteR9kHYx2MyP3JnUd7z8m/view")[Participare] & premiul 3 \@ Cognizant Softvision], issuer: [CodeRun], ) #cvHonor( date: [2023], title: [#link("https://drive.google.com/file/d/1SBUgEqI3Z-jnr1mAVzYDrcdMqNi6UTGN/view")[Participare]], issuer: [Bootcamp STS], ) #cvSection("Certificate") #cvHonor( date: [2019], title: [#link("https://drive.google.com/file/d/15JN-Ko_CXP_WKGsrRxdQNzniaNkSrgTx/view")[Certificat de completare]], issuer: [Digital Nation], ) #cvHonor( date: [2020], title: [#link("https://drive.google.com/file/d/1Ahga9TNBsfRH_j3DBIsywD5D3XRbzElf/view")[Certificat de cunoaștere PHP]], issuer: [Digital Nation], ) #cvHonor( date: [2023], title: [#link("https://drive.google.com/file/d/1-IKzgJgB8cK2fZ3cvvYGLBRQKGds8YUM/view")[Curs de Python]], issuer: [UTCN], )
https://github.com/janlauber/bachelor-thesis
https://raw.githubusercontent.com/janlauber/bachelor-thesis/main/thesis_typ/abstract_en.typ
typst
Creative Commons Zero v1.0 Universal
#let abstract_en() = { set page( margin: (left: 25mm, right: 25mm, top: 25mm, bottom: 25mm), numbering: none, number-align: center, ) let body-font = "New Computer Modern" let sans-font = "New Computer Modern Sans" set text( font: body-font, size: 12pt, lang: "en" ) set par( leading: 1em, justify: true ) // --- Abstract (EN) --- v(1fr) align(center, text(font: body-font, 1em, weight: "semibold", "Abstract")) text[ This thesis explores how the One-Click Deployment system enhances the deployment of open-source software by leveraging Kubernetes. By simplifying the complexities involved, the system aims to democratize access to these powerful features, making it easier for users of all technical levels to benefit from advanced container orchestration. The deployment of open-source software and frameworks often involves complex and challenging processes, which can limit accessibility and adoption. Many users find it difficult to manage dependencies, scale applications, and ensure consistent environments across different stages of development. The One-Click Deployment system addresses these challenges by encapsulating Kubernetes' strengths within a user-friendly interface. This system simplifies deployment, scaling, and management processes, making these advanced capabilities available to a broader audience. Through iterative development and user feedback, the system has been refined to balance ease of use with robust functionality. The primary objective of this project is to enhance the accessibility and usability of Kubernetes, enabling users to deploy and manage open-source software more efficiently. By providing a unified deployment solution that streamlines the process, the system empowers users to focus on their applications' development and innovation, rather than the complexities of deployment. The One-Click Deployment system has successfully made the strengths of Kubernetes more accessible, significantly reducing the need for specialized knowledge. Users reported notable improvements in deployment efficiency and ease of management, highlighting the system's effectiveness in simplifying complex processes. Future enhancements will focus on further improving the user experience, integrating additional Kubernetes features, and ensuring robust security measures. Ongoing user feedback will drive the continuous improvement of the system, ensuring it meets the evolving needs of the open-source community. The system is open-source and available under the Apache 2.0 license on GitHub, with repositories for both the One-Click Operator and the One-Click system. This commitment to open-source principles fosters broad collaboration and continuous enhancement, further supporting its goal of making advanced deployment capabilities accessible to all. ] v(1fr) }
https://github.com/jgm/typst-hs
https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/layout/enum-00.typ
typst
Other
#enum[Embrace][Extend][Extinguish]
https://github.com/alberto-lazari/computer-science
https://raw.githubusercontent.com/alberto-lazari/computer-science/main/mobile-programming/exam-presentation/presentation.typ
typst
#import "typst-slides/slides.typ": * #import "typst-slides/themes/bristol.typ": * // Path is based on the theme path #let img-dir = "../../images/" #let unipd-red = rgb(178, 14, 16) #show: slides.with( authors: "<NAME> - 2089120", short-authors: "<NAME>", title: "The PNG format for digital images encoding", subtitle: "Mobile Programming & Multimedia exam presentation", short-title: "The PNG format", date: "June 26, 2023", theme: bristol-theme( color: unipd-red, logo: img-dir + "unipd-logo.png", watermark: img-dir + "blank.png", secondlogo: img-dir + "blank.png", ) ) // Make the section name more visible and distinct from the title #let new-section = name => { new-section([ #set text(size: 20pt, weight: "bold"); #name ]) } // Custom wake up #let wake-up = content => [ #set align(center) #set text(weight: "bold") #slide(theme-variant: "wake up")[#content] ] #set text(font: "Arial") // Add background to monospace text #show raw.where(block: false): box.with( fill: luma(220), inset: (x: 3pt, y: 0pt), outset: (y: 8pt), radius: 4pt, ) #show raw.where(block: true): block.with( fill: luma(220), inset: 10pt, radius: 10pt, ) #show figure: itself => [ #set text(size: 16pt) #itself ] #slide(theme-variant: "title slide") #new-section("The history of GIF") #slide(title: "Let's talk about GIF first")[ // Start with empty slide // on the second sub-slide start the list #show: pause(2) #line-by-line(start: 2, mode: "transparent")[ - Released in 1987 - First format for image transmission over a network - Provides animations and transparency - Indexed colors (8 bits - 256 colors) - Lossless compression using LZW ] ] #wake-up[ #set align(center) #set text(weight: "bold") Everything was great#uncover(2)[, until it wasn't] ] #slide(title: "Licensing")[ In 1994 Unisys patented the LZW algorithm $==>$ *pay royalties* to support the format! #uncover(2)[(until 2004)] ] #new-section("PNG's birth") #slide(title: "Time to PING!")[ #one-by-one[- Users started to plan a *free* alternative][- GIF's lack of true color support]["PING Is Not GIF" was born!][ Later renamed to "Portable Network Graphics" (PNG) ] ] #slide(title: "Features")[ #line-by-line(mode: "transparent")[ - True color, grayscale and indexed colors support - Optional alpha channel - Lossless #text(size: 19pt)[_(non-patented!)_] compression algorithm - Interlacing for low-resolution image earlier in the transfer - Gamma correction - Extensible (e.g. add different chunks) ] ] #new-section("Features") #slide(title: "Color depth")[ #only(1)[ True color has 8/16 bits per channel #figure( grid( columns: (1fr, 1fr), image("images/test-images/pelmo.gif", width: 80%), image("images/test-images/pelmo.png", width: 80%), ), caption: "GIF vs PNG" ) ] #only(2)[ Also supports indexed colors (1-8 bits - max 256 colors) #figure( grid( columns: (1fr, 1fr), image("images/test-images/pelmo.gif", width: 80%), image("images/test-images/pelmo-indexed.png", width: 80%), ), caption: "GIF vs PNG with indexed colors" ) ] #only(3)[ Grayscale also supported (1-16 bits per pixel) #figure( image("images/test-images/pelmo-grayscale.png", width: 40%), caption: "Grayscale PNG" ) ] ] #slide(title: "Color model")[ Either RGB or RGBA for transparency, focus on artificial images Human color perception out of PNG scope $->$ no YUV / YCbCr with specific optimizations (see JPEG) ] #slide(title: "Compression")[ - Uses DEFLATE algorithm - Combination of LZ77 (or LZ1) and Huffman - Also implemented in zlib and default compression method in `zip` utility: ```bash $ zip --compression-method=deflate archive.zip dir/* ``` ] #slide(title: "Interlacing")[ #grid( columns: (3fr, 2fr), [ - Optional 2-dimensions, 7-pass algorithm (Adam7) - Allows low-resolution preview of the image - For slower connections #uncover(2)[ - #text(unipd-red)[Worse compression performances] ] ], figure( image("images/adam7.png", height: 40%), caption: "Adam7 algorithm visualization", ), ) ] #slide(title: "Interlacing - example")[ #for i in range(1, 8) { only(i)[ #figure( image("images/test-images/vesuvio-" + str(i) + ".png", width: 45%), caption: "Pass " + str(i), ) ] } ] #new-section("Animations") #slide(title: "What about animations?")[ MNG (Multiple-image Network Graphics) First attempt to mimic GIF's animated pictures #uncover(2)[ Complex and different file signature $=>$ never widely adopted ] ] #slide(title: "APNG (Animated PNG)")[ #line-by-line(mode: "transparent")[ - Proposed by Mozilla developers - PNG-compatible - Lighter than MNG - Support by most browsers - Not officially embraced by PNG Group ] ] #new-section("WebP") #slide(title: "Future of PNG?")[ #grid( columns: (4fr, 1fr), [ WebP aims to replace PNG, JPEG and GIF: #line-by-line(start: 2, mode: "transparent")[ - Both lossy and lossless compression - Animation and transparency support - Great compression performances - Actively promoted by Google - Still not widespread ] ], figure([ #v(15%); #image("images/webp.png") ]) ) ] #wake-up[ Thanks for your attention! ]
https://github.com/Wh4rp/Presentacion-Typst
https://raw.githubusercontent.com/Wh4rp/Presentacion-Typst/master/ejemplos/12_show.typ
typst
#show "Ping": "Pong" Ping #show "Hola mundo": val => [#text(blue)[#val]] Hola mundo
https://github.com/El-Naizin/cv
https://raw.githubusercontent.com/El-Naizin/cv/main/modules_zh/professional.typ
typst
Apache License 2.0
#import "../brilliant-CV/template.typ": * #cvSection("职业经历") #cvEntry( title: [数据科学主管], society: [XYZ 公司], logo: "../src/logos/xyz_corp.png", date: [2020 - 现在], location: [旧金山, CA], description: list( [领导数据科学家和分析师团队,开发和实施数据驱动的策略,开发预测模型和算法以支持组织内部的决策], [与高级管理团队合作,确定商业机会并推动增长,实施数据治理、质量和安全的最佳实践] ) ) #cvEntry( title: [数据分析师], society: [ABC 公司], logo: "../src/logos/abc_company.png", date: [2017 - 2020], location: [纽约, NY], description: list( [使用 SQL 和 Python 分析大型数据集,与跨职能团队合作以识别商业洞见], [使用 Tableau 创建数据可视化和仪表板,使用 AWS 开发和维护数据管道] ) ) #cvEntry( title: [数据分析实习生], society: [PQR 公司], logo: "../src/logos/pqr_corp.png", date: [2017年夏季], location: [芝加哥, IL], description: list( [协助使用 Python 和 Excel 进行数据清洗、处理和分析,参与团队会议并为项目规划和执行做出贡献], [开发数据可视化和报告以向利益相关者传达洞见,与其他实习生和团队成员合作以按时并高质量完成项目] ) )
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/minitoc/0.1.0/README.md
markdown
Apache License 2.0
# Typst miniTOC This package provides the `minitoc` command that does the same thing as the `outline` command but only for headings under the heading above it. This is inspired by minitoc package for LaTeX. ## Example ```typst #import "@preview/minitoc:0.1.0": * #set heading(numbering: "1.1") #outline() = Heading 1 #minitoc() == Heading 1.1 #lorem(20) === Heading 1.1.1 #lorem(30) == Heading 1.2 #lorem(10) = Heading 2 ``` This produces ![](https://gitlab.com/human_person/typst-local-outline/-/raw/main/example/example.png) ## Usage The `minitoc` function has the following signature: ```typst #let minitoc( title: none, target: heading.where(outlined: true), depth: none, indent: none, fill: repeat([.]) ) { /* .. */ } ``` This is designed to be as close to the [`outline`](https://typst.app/docs/reference/meta/outline/) funtions as possible. The arguments are: - **title**: The title for the local outline. This is the same as for [`outline.title`](https://typst.app/docs/reference/meta/outline/#parameters-title). - **target**: What should be included. This is the same as for [`outline.target`](https://typst.app/docs/reference/meta/outline/#parameters-target) - **depth**: The maximum depth different to include. For example, if depth was 1 in the example, "Heading 1.1.1" would not be included - **indent**: How the entries should be indented. Takes the same types as for [`outline.indent`](https://typst.app/docs/reference/meta/outline/#parameters-indent) and is passed directly to it - **fill**: Content to put between the numbering and title, and the page number. Same types as for [`outline.fill`](https://typst.app/docs/reference/meta/outline/#parameters-fill) ## Unintended consequences Because `minitoc` uses `outline`, if you apply numbering to the title of outline with `#show outline: set heading(numbering: "1.")` or similar, any title in `minitoc` will be numbered and be a level 1 heading. This cannot be changed with `#show outline: set heading(level: 3)` or similar unfortunately.
https://github.com/saecki/zig-grep
https://raw.githubusercontent.com/saecki/zig-grep/main/paper/paper.typ
typst
#import "template.typ": * #import "@preview/codelst:1.0.0": sourcecode #let title = "Writing a grep like program in Zig" #let author = "<NAME>" #show: project.with(title: title, author: author) // Title page #{ set page(numbering: none) set align(center) v(1.2fr) image("zigfast.png", width: 80%) cite(<zigfast_logo>) v(1.2fr) text(2em, title) v(0.6fr) text(1.6em, "Seminar Programming Languages") v(0.6fr) text(1.2em, weight: "bold", author) v(0.3fr) text(1.2em, datetime.today().display()) v(1.2fr) } // Outline. #outline(indent: true) #pagebreak() // Main body. #set par(justify: true) = Introduction The objective of this seminar was getting to know a new programming language by writing a simple grep @grep like program. It should be able to support unicode in the form of `UTF-8`, filter out binary files, print a help message, pass a test-suite, and adhere to the following command line interface: #output[``` usage: searcher [OPTIONS] PATTERN [PATH ...] -A,--after-context <arg> prints the given number of following lines for each match -B,--before-context <arg> prints the given number of preceding lines for each match -c,--color print with colors, highlighting the matched phrase in the output -C,--context <arg> prints the number of preceding and following lines for each match. this is equivalent to setting --before-context and --after-context -h,--hidden search hidden files and folders --help print this message -i,--ignore-case search case insensitive --no-heading prints a single line including the filename for each match, instead of grouping matches by file ```] = Language Zig is a general-purpose compiled systems programming language @ziglang. It was initially developed by <NAME> and released in 2016 @zig_introduction. Today development is funded by the Zig software foundation (ZSF), which is a nonprofit (`501(c)(3)`) corporation stationed in New York @zig_software_foundation. Zig is placed as a successor to C, it is an intentionally small and simple language, with its whole syntax fitting in a 500 line PEG grammar file @zigdoc_grammar. If focuses on readability and maintainability restricting the control flow only to language keywords and function calls @ziglang_overview. == Toolchain Installation was as simple as downloading the release tar archive from the downloads section of the Zig website @ziglang_downloads, extracting the toolchain, and symlinking the binary onto a `$PATH`. There is also a community project named `zigup` @zigup which is allows installing and managing multiple versions of the Zig compiler. The compiler is a single executable named `zig`, it includes a build system which can be configured in a `build.zig` file, which is written in Zig @ziglang_buildsystem. The toolchain itself is also a C/C++ compiler which allows Zig code to directly interoperate with existing C/C++ code @ziglang_overview_c_integration. To create a new project inside the current directory, run `zig init-exe`. This will generate the main source file `src/main.zig` and the build configuration `build.zig`. The program can then be built and executed by running `zig build run`. @ziglang_getting_started The Zig community also provides a language server named `zls` @zls, which worked right away after setting it up in `neovim` @neovim. There were some issues with type inference, and completion of member functions of generic types. In some cases `zls` would report no errors when the Zig compiler would. #pagebreak(weak: true) == Integers Zig has concrete integer types with a predetermined size regardless of the target platform. Commonly used types are: - unsigned: `u8`, `u16`, `u32`, `u64` - signed: `i8`, `i16`, `i32`, `i64`. But it also allows defining both signed and unsigned, arbitrary sized integers like `i27`, or `u3`, up to a maximum bit-width of `65535` @zigdoc_integers. == Arrays and slices Zig arrays @zigdoc_arrays have a size known at compile time and are stack allocated, unless specified otherwise: #sourcecode[```zig const explicit_length = [5]u32{ 0, 1, 2, 3, 4 }; const inferred_length = [_]u32{ 5, 6, 7, 8, 9 }; ```] Arrays can be sliced using the index operator with an end-exclusive or half-open range, returning a slice @zigdoc_slices to the referenced array. By default the slice is a fat pointer which is composed of a pointer that points to the memory address of the slice inside the array, and the length of the slice: #sourcecode[```zig const array = [_]u32{ 0, 1, 2, 3, 4 }; const slice = array[1..3]; std.debug.print("{*}\n{d}\n", .{ slice, slice.* }); ```] The code prints the fat pointer itself, and the dereferenced values of the array it points to: #output[``` [2]u32@2036fc { 1, 2 } ```] For better interoperability with C Zig also allows sentinel terminated pointers @zigdoc_pointers or slices. Most commonly this is used for null-terminated strings: #sourcecode[```zig const string: *const [32:0]u8 = "this is a null terminated string"; const fat_pointer_slice: []const u8 = string[10..]; const null_term_slice: [:0]const u8 = string[10..]; const null_term_ptr: [*:0]const u8 = string[10..]; std.debug.print("size: {}, '{s}'\n", .{@sizeOf([]const u8), fat_pointer_slice}); std.debug.print("size: {}, '{s}'\n", .{@sizeOf([:0]const u8), null_term_slice}); std.debug.print("size: {}, '{s}'\n", .{@sizeOf([*:0]const u8), null_term_ptr}); ```] The code prints the size of the pointer and the string it references: #output[``` size: 16, 'null terminated string' size: 16, 'null terminated string' size: 8, 'null terminated string' ```] All three slice/pointer types reference the same data, but in a different way. Variant 1 uses the fat pointer approach described above. Variant 2 uses the same approach but also upholds the constraint that the end of the slice is terminated by a null-byte sentinel. Variant 3 only stores a memory address and relies upon the null-byte sentinel to compute the length of the referenced data when needed.\ On 64-bit target platforms the first and the second slice type have a size of 16 bytes, 8 bytes for the pointer and 8 additional bytes for the length. The sentinel terminated pointer only has a size of 8 bytes, since it does not store an additional length field. A limitation of sentinel terminated slices or pointers is that they cannot reference arbitrary parts of an array. Trying to do so fails with the following message: #output[``` src/main.zig:10:62: error: expected type '[:0]const u8', found '*const [13]u8' const null_terminated_string_slice: [:0]const u8 = string[10..23]; ~~~~~~^~~~~~~~ src/main.zig:10:62: note: destination pointer requires '0' sentinel ```] == Tagged unions In Zig tagged unions are very similar to Rust enums @rustbook_enums. The tag can be either an existing enum or inferred from the union definition itself. If an existing enum is used as a tag, the compiler enforces that every variant that the enum defines is present in the union declaration. Tagged unions can be coerced to their enum tag, and an enum tag can be coerced to a tagged union when it is known at `comptime` and the union variant type has only one possible value such as `void`. @zigdoc_tagged_union #sourcecode[```zig const TokenType = enum { Ident, IntLiteral, Dot, }; const Token = union(TokenType) { Ident: []const u8, IntLiteral: u64, Dot, }; const ident_token = Token { .Ident = "abc" }; const token_type: TokenType = ident_token; // `Token.Dot` has only one value const dot_token: Token = TokenType.Dot; ```] == Type inference The type of Zig variables is inferred using only directly assigned values. A type can optionally be specified, and is required in some cases. For example when an integer literal is assigned to a mutable variable, its exact type must be specified. When the type of a `struct` is known, such as when passing it to a function, its name can be omitted and an anonymous literal can be used: #sourcecode[```zig const Foo = struct { a: i32, b: bool = false, }; fn doSomething(value: Foo) void { ... } doSomething(.{ .a = 21 }); ```] #pagebreak(weak: true) The same is also true for an `enum` and a tagged `union`. When the type is known, the name of the `enum` can be omitted and only the variant needs to written out: #sourcecode[```zig const Bar = enum { One, Two, }; const BAR_TWO: Bar = .Two; const Value = union(enum) { Int: u32, Float: f32, Bool: bool, }; const INT_VAL: Value = .{ .Int = 324 }; ```] == Control flow Zig has special control flow constructs for dealing with union and optional values. Optional values can be passed into an if statement and if a non-null value is contained, it can be accessed inside the if statement's body: #sourcecode[```zig const optional_int: ?u32 = 86; if (optional_int) |int| { std.debug.print("Contains int {}\n", .{int}); } ```] To unwrap optional values more conveniently zig provides the `orelse` operator which allows specifying a default value, and the `.?` operator which forces a value to be unwrapped and will crash if it is `null`: #sourcecode[```zig const optional_token: ?Token = parser.next(); const token = optional_token orelse unreachable; // syntax sugar for the above const token = optional_token.?; ```] Switch statements can be used to extract the values of tagged unions in a similar way: #sourcecode[```zig switch (token) { .Ident => |ident| { std.debug.print("Identifier: '{}'", .{ident}); } .IntLiteral => |int| { std.debug.print("Integer literal: '{}'", .{int}); } .Dot => {}, } ```] #pagebreak(weak: true) == Error handling In Zig there are no exceptions and errors are treated as values. If a function is fallible it returns an error union, the error set of that union can either be inferred or explicitly defined: #sourcecode[```zig // inferred error set pub fn main() !void { const num = try std.fmt.parseInt(u32, "324", 10); // ^ unwraps or returns the error std.debug.print("{d}\n", .{num}); } // named error set const IntError = error{ IsNull, Invalid, }; fn checkNull(num: usize) IntError!void { if (num == 0) { return error.IsNull; } } ```] Like optional values, error unions can be inspected using an if statement. The only difference is that the else clause now also grants access to the error value: #sourcecode[```zig fn fallibleFunction() !f64 { ... } if (fallibleFunction()) |val| { std.debug.print("Found value: {}\n", .{val}); } else |err| { std.debug.print("Found error: {}\n", .{err}); } ```] And likewise the `catch` operator for error unions corresponds to the `orelse` operator of optionals: #sourcecode[```zig const DEFAULT_PATH = "$HOME/.config/zig-grep"; const path = readEnvPath() catch DEFAULT_PATH; ```] Additionally the `catch` operator allows capturing the error value.\ Similar to Rust @rustbook_try Zig has a `try` operator that either returns the error of an error union from the current function or unwraps the value: #sourcecode[```zig const file = openFile() catch |err| return err; // syntax sugar for the above const file = try openFile(); ```] #pagebreak(weak: true) == Defer There are no constructors or destructors in Zig, so unlike C++ where the RAII @cppref_raii model is often used to make objects manage their resources automatically, resources have to be managed manually. A commonly used pattern to manage resources is for an object to define `init` and a `deinit` procedures, which have to be called manually. In that case the `init` procedure is a static member function on the type that returns an instance of the type, and the `deinit` procedure is a method of the object. To make this more ergonomic Zig provides `defer` statements, which allow running cleanup code when a value goes out of scope. If multiple `defer` statements are defined, they are run in reverse declaration order. This allows the deinitialization code to be directly below the initialization @zigdoc_defer: #sourcecode[```zig fn fallibeFunction() ![]const u8 { var foo = try std.fs.cwd().openFile("foo.txt", .{}); defer foo.close(); var bar = try std.fs.cwd().openFile("bar.txt", .{}); defer bar.close(); // the defer statements will be executed in this order: // 1. bar.close(); // 2. foo.close(); } ```] The `errdefer` statement runs code *only* when an error is returned from the scope, this can be useful when dealing with a multi step initialization process that can fail, and intermediate resources need to be cleaned up @zigdoc_errdefer: #sourcecode[```zig fn openAndPrepareFile() !File { var file = try std.fs.cwd().openFile("foo.txt", .{}); errdefer file.close(); try file.seekBy(8); return file; } ```] If the function succeeds the file is returned from it, so it should not be closed. If it fails while seeking and returns an error, the `errdefer` statement is executed and the file is closed as to not leak any resources. == Memory management Zig does not include a garbage collector and uses a very explicit manual memory management strategy. Memory is manually allocated and deallocated via `Allocator`s that are choosen and instantiated by the user. Data structures or functions which might allocate require an allocator to be passed explicitly. The standard library includes a range of allocators fit for different use cases, ranging from general purpose bucket allocators, bump- or arena allocators, to fixed buffer allocators.\ Memory allocation may fail, and out of memory errors must be handled. Memory deallocation must always succeed. Like other resources, data structures that allocate commonly provide an `init` and `deinit` procedure which can be used in combination with a `defer` statement to make sure allocated memory is freed.\ In debug mode the `GeneralPurposeAllocator` keeps track of allocations and detects memory leaks and double frees @zigdoc_std_gpa. == Comptime Zig provides a powerful compile time evaluation mechanism to avoid using macros or code generation. Contrary to C++ or Rust where functions have to be declared `constexpr` @cppref_constexpr or `const` @rustref_const in order to be called at compile time, in Zig everything that can be evaluated at `comptime` just is. A function called from a `comptime` context will either yield an error explaining what part of it is not able to be evaluated at `comptime` or evaluate the value during compilation. A `comptime` context can be a constant defined at the global scope, or a `comptime` block. @zigdoc_comptime This can be used to do expensive calculations, generate lookup tables, or uphold constraints using assertions, all at compile time: #sourcecode[```zig const FIB_8 = fibonacci(8); comptime { // won't compile std.debug.assert(fibonacci(3) == 1); } fn fibonacci(n: usize) u64 { if (n == 0 or n == 1) { return 1; } return fibonacci(n - 1) + fibonacci(n - 2); } ```] This means, if the main function is able to be evaluated at compile time, and it is called from a `comptime` context, the Zig compiler acts as an interpreter and the program is executed during compilation. Granted since comptime code can not perform I/O such a program is quite limited. Arguments to functions can be declared as `comptime` which requires them to be known during compilation. This is often used for types passed to function in the same way other languages handle generics. Considering the following Kotlin @kotlinlang class: #sourcecode[```kotlin class Container<T>( var items: ArrayList<T>, ) ```] An equivalent Zig `struct` would be defined as a function taking a `comptime` type as an argument that returns another type: #sourcecode[```zig fn Container(comptime T: type) type { return struct { items: ArrayList(T), } } ```] Note that ArrayList is another such function defined in the standard library. #pagebreak(weak: true) == SIMD In addition to the automatic vectorization of code that the LLVM @llvm optimizer does, Zig also provides a way to explicitly define vector operations, using the `@Vector` intrinsic, that will compile down to target specific SIMD operations: @zigdoc_vectors #sourcecode[```zig const a = @Vector(4, i32){ 1, 2, 3, 4 }; const b = @Vector(4, i32){ 5, 6, 7, 8 }; const c = a + b; ```] == Ecosystem Compared to C++, Java, or Rust the standard library of Zig is quite minimal. Neither the Zig language itself, nor the standard library directly define a string datatype. String literals are represented as byte slices (`[]const u8`), which allows using the whole range of `std.mem.*` functions to operate on them. With Zig being a young language, the eco system in general is still a little immature. To date there is no regex library written in zig that has feature parity with established regex engines. Zig `0.11.0` does not include support for `async` functions @zig_postponed_again. #pagebreak(weak: true) = Development process Since the scope of the program was predetermined, I mainly focused on performance. == Directory walking The Zig standard library provides `IterableDir`, an iterator for traversing a directory in a depth first manner, but unfortunately that approach does not allow filtering of searched directories. To overcome that limitation I mostly copied the standard library function for walking directories and modified it slightly to allow filtering out hidden directories. == Linking and using the regex engine Since there are no usable regex engines written in Zig I had to find a library written in another language. I decided on using the Rust regex library (`rure`) @rust_regex through its C API, because it is a standalone project, easy to build @rustbook_cargo_build, and reasonably fast @rebar.\ To include a C library, some modification inside the `build.zig` configuration file are needed: #sourcecode[```zig // link all the other stuff needed exe.linkLibC(); exe.linkSystemLibrary("util"); exe.linkSystemLibrary("dl"); exe.linkSystemLibrary("gcc_s"); exe.linkSystemLibrary("m"); exe.linkSystemLibrary("rt"); exe.linkSystemLibrary("util"); // link rure itself exe.addIncludePath(LazyPath.relative("rure/regex-capi/include")); exe.addLibraryPath(LazyPath.relative("rure/target/release")); exe.linkSystemLibrary2("rure", .{ .needed = true, .preferred_link_mode = .Static, }); ```] This links the `rure` crate statically into the final binary. The dependencies are taken straight from the `rure` compile script: #sourcecode[```sh # N.B. Add `--release` flag to `cargo build` to make the example run faster. cargo build --manifest-path ../Cargo.toml gcc -O3 -DDEBUG -o iter iter.c -ansi -Wall -I../include -L../../target/debug -lrure # If you're using librure.a, then you'll need to link other stuff: # -lutil -ldl -lpthread -lgcc_s -lc -lm -lrt -lutil -lrure ```] When linking C libraries, Zig is not able to include debug symbols, so crash messages that would normally be informative, only show memory addresses: <debug_symbols> #output[``` thread 20843 panic: index out of bounds: index 14958, len 14948 Unwind error at address `:0x2ebaef` (error.InvalidDebugInfo), trace may be incomplete ```] This is a known issue @ziglang_issue_12046. #pagebreak(weak: true) The C functions can then be imported using the `@cImport` intrinsic: #sourcecode[```zig const c = @cImport({ @cInclude("rure.h"); }); ```] And the C definitions can be accessed using the returned object: #sourcecode[```zig var match: c.rure_match = undefined; const found = c.rure_find(ctx.regex, @ptrCast(text), text.len, pos, &match); ```] == Single threaded optimization The program was profiled in an end to end manner using `hyperfine` @hyperfine. === Line by line searching To keep it simple, the first implementation reads the whole file into a single buffer and runs a pre-compiled regex search on every line. Regex pattern matching is done using a regex iterator from the `rure` crate. === Whole text searching After some investigation it turned out that initializing the regex iterator provided by the `rure` crate had more overhead than expected, and running the regex search on the whole text instead of every line would improve performance significantly. Following this change, I found out that the `rure` library also provided a function that allowed searching from a specified start index inside the passed text slice. Using this function avoided allocating the iterator in the first place. === Line by line searching with fixed size buffer Since one of the tests was to search an 8Gb large text file, the input would need to be split up into smaller chunks as to avoid running out of memory. This is done using a fixed size buffer which only loads part of the file, searching that buffer up to the last fully included line, then moving the unsearched parts including possibly relevant context lines to the start of the buffer, and eventually refilling the buffer with remaining data to search. Since lines need to be iterated anyway to calculate line numbers, and the implementation was now using the function that searches the text directly without an iterator, I decided to once again search each line individually, instead of the whole text. === Whole text searching with fixed size buffer After further investigation I discovered that the overhead of searching each line did not just come from the `rure` iterator, but that special regex patterns introduced large overhead when starting the search. One example was the word character pattern `\w`, which has to respect possibly multi-byte unicode characters. Since the `rure` library uses a finite automata (state machine), matching multiple word characters results in a large number of states @rust_regex_issue_1095. This state machine, although only compiled once, needs to be initialized in memory every time a search is started. Disabling unicode support during the regex pattern compilation significantly improves performance. With these findings, the regex pattern matching was once again adjusted to be run on the whole text buffer, to restore previously achieved performance. One additional bug that I only tackled at this stage was to prevent regex matches that spanned multiple lines. If a match is found that spans multiple lines an additional search is run only on the first matched line, if it succeeds too, only this match is highlighted and printed, otherwise it is a false positive. == Parallelization At this point most easy wins in single threaded optimization were off the table, so the next major performance improvements would come from using multiple threads. The most time consuming sections of the program are accessing the file system, and searching the text. Parallelization of text searching was implemented using a thread pool of workers that would receive file paths through an atomically synchronized, ring-buffer message queue (`AtomicQueue` in `src/atomic.zig`). The message queue synchronization is implemented using a mutex for exclusive access and use a futex @futex as an event system to notify other workers when the state has changed. Workers wait for a new message from the queue and receive either a path to search or a stop signal: #sourcecode[```zig while (true) { var msg = ctx.queue.get(); switch (msg) { .Some => |path| { defer ctx.allocator.free(path.abs); try searchFile(&ctx, text_buf, &line_buf, &path); }, .Stop => break, } } ```] The directory walking remains mostly the same apart from searching files ad hoc, they were now sent through the message queue. Since there are now multiple threads writing to `stdout` their output has to be synchronized so that lines from one file would not be interspersed with other ones.\ There are two obvious solutions to this problem. One is to use a dynamically growing allocated buffer which stores the entire output of a searched file and then write the entire buffer in a synchronized way when the file is fully searched. This would avoid blocking other threads, but could cause the program to run out of memory if large portions of big files would match a search pattern.\ The other solution is to block output of all other threads once a match has been found in a file and then write all lines directly to `stdout`. This would avoid running out of memory, but could in worst case scenarios cause close to single threaded performance.\ The final implementation uses a hybrid of the two, each thread has a fixed size output buffer which can be written to without any locking (`SinkBuf` in `src/atomic.zig`). Once the buffer is full, access to `stdout` is locked using the underlying thread safe writer (`Sink` in `src/atomic.zig`) and the thread is free to write to it until the file is fully searched. While `stdout` is locked, other workers can still make progress and access their thread-local output buffers. With only text searching parallelized the search workers were consuming messages from the queue faster than paths could be added, so the goal was to speed up walking the file system with multiple threads.\ This was heavily influenced by the Rust `ignore` crate @ignore_crate which is also used in `ripgrep` @ripgrep. A thread pool of walkers is used to search multiple directories simultaneously in a depth first manner to reduce memory consumption.\ The core data structure used is an atomically synchronized, priority stack (`AtomicStack` in `src/atomic.zig`). A walker tries to pop off a directory of a shared atomically synchronized stack, by blocking until one is available. Once it receives a directory it iterates through the remaining entries, enqueuing any files encountered. If it encounters a subdirectory, the parent directory is pushed back onto the stack and the subdirectory is walked. The stack keeps track of the number of waiting threads and once all walkers are waiting for a new message, all directories have been walked completely and the thread pool is stopped: #sourcecode[```zig self.alive_workers -= 1; if (self.alive_workers == 0) { self.state.store(@intFromEnum(State.Stop), std.atomic.Ordering.SeqCst); Futex.wake(&self.state, std.math.maxInt(u32)); return .Stop; } ```] == Command line argument parsing Argument parsing makes use of tagged unions and `comptime`. There are two different types of arguments: flags and values, both of these are defined as enums. While flags are just boolean toggles, values require for example a number, to be specified after them. `UserArgKind` is a tagged union that contains either one or the other: #sourcecode[```zig const UserArgKind = union(enum) { value: UserArgValue, flag: UserArgFlag, }; const UserArgValue = enum(u8) { Context, AfterContext, BeforeContext, }; const UserArgFlag = enum(u8) { Hidden, FollowLinks, Color, ... }; ```] All user arguments are defined in an array, including their long form, an optional short form, a description and their union representation: #sourcecode[```zig const USER_ARGS = [_]UserArg{ .{ .short = 'A', .long = "after-context", .kind = .{ .value = .AfterContext }, .help = "prints the given number of following lines for each match", }, ... .{ .short = null, .long = "help", .kind = .{ .flag = .Help }, .help = "print this message", }, ... }; ```] When parsing command line arguments this can be used to exhaustively match all possible valid inputs using a switch statement. When adding a new enum variant the compiler enforces it is handled in all switch statements that match the modified enum. This is the simplified switch statements that handles all arguments: #sourcecode[```zig switch (user_arg.kind) { .value => |kind| { switch (kind) { .Context => { opts.after_context = num; opts.before_context = num; }, ... } }, .flag => |kind| { switch (kind) { .Hidden => opts.hidden = true, ... } }, } ```] The help message is generated at `comptime`, using the list of possible arguments.\ Instead of a general purpose allocator a fixed buffer allocator had to be used, but otherwise the code could be written without taking any precautions. #pagebreak(weak: true) == Compiler bug With Zig `0.11.0` I encountered a bug in the compiler which would affect command line argument parsing. In debug mode arguments were parsed as expected, but in release mode the `--ignore-case` flag would be parsed as the `--hidden` flag. All flags are defined as an `enum`: #sourcecode[```zig const UserArgFlag = enum { Hidden, FollowLinks, Color, NoHeading, IgnoreCase, Debug, NoUnicode, Help, }; ```] The issue was fixed by specifying a concrete tag type to represent the enum instead of letting the compiler infer the type: #sourcecode[```diff @@ -27,12 +27,12 @@ const UserArgKind = union(enum) { flag: UserArgFlag, }; -const UserArgValue = enum { +const UserArgValue = enum(u8) { Context, AfterContext, BeforeContext, }; -const UserArgFlag = enum { +const UserArgFlag = enum(u8) { Hidden, FollowLinks, Color, ```] At the time I discovered the bug, it was already fixed on the Zig `master` branch.\ I was not able to find a github issue or a pull request related to this bug, but my best guess is that the enum was somehow truncated to two bits, which would strip the topmost bit of the `IgnoreCase` variant represented as `0b100`, resulting in `0b00` which corresponds to `Hidden`. #pagebreak(weak: true) = Conclusion == Program Using Zig I was able to write a program that is only around 2-3 times as slow as `ripgrep` @ripgrep when run on the test-suite, see @bench. Since the Zig compiler as of version `0.11.0` is not able to generate debug symbols when a C library is linked, I could not profile the program more thoroughly. I would have liked to look at a `flamegraph` @flamegraph and more detailed timing information to optimize the application. The program also currently synchronizes output for entire files, even if the `--no-heading` option is enabled. It should be faster to only synchronize output for lines, especially when a large file might be blocking other threads from progressing to the next file, because it has filled its output buffer, has exclusive access to `stdout` and prevents them from flushing their output buffer. == Language While having several constructs that make it easier to write memory safe code than C, like optional types, `defer` statements, or a slice type with a length field, Zig is still an unsafe language regarding memory management. Compared to managed languages with garbage collectors or Rust that has hard rules in place to avoid double frees, data races, and to some degree memory leaks, a program written in Zig still places a burden on the programmer to avoid memory related bugs. But this is done for a reason, Zig allows competent programmers to write high performance code while taking full control of the system. It does so while being more ergonomic than C and being less constraining than Rust. #pagebreak(weak: true) = Bibliography #bibliography( "literature.yml", title: none, style: "ieee" ) #pagebreak(weak: true) = Benchmark results <bench> The raw benchmark output can be found in the `bench` directory. Benchmarks were run using `python 3.11.7`, `hyperfine 1.18.0` @hyperfine and a modified version of the test-suite which can be found at `test/test.py`. By default `hyperfine` runs each command at least 10 times. The exact command used to run the benchmarks was: #sourcecode[```sh python test/test.py --ripgrep -v --bench --fail-fast -d test/data ./zig-out/bin/zig-grep ```] == Result from a thinkpad with an Ryzen 7 5800u and 16Gb ram #table( columns: (6fr, 3fr, 3fr, 1fr), align: center, [], [ripgrep [ms]], [searcher [ms]], [], ) #v(0fr) #table( columns: (6fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr), align: (x, y) => if x > 0 { right } else { left }, [name], [min], [avg], [max], [min], [avg], [max], [%], [literal_linux], [149], [162], [211], [341], [346], [360], [213], [literal_linux_hidden], [174], [179], [191], [405], [417], [430], [231], [linux_literal_ignore_case], [172], [176], [185], [391], [400], [405], [227], [linux_pattern_prefix], [164], [168], [179], [381], [394], [398], [234], [linux_pattern_prefix_with_context], [171], [174], [181], [383], [394], [399], [225], [linux_pattern_prefix_ignore_case], [179], [186], [192], [431], [446], [457], [239], [linux_pattern_suffix], [172], [178], [184], [528], [537], [544], [301], [linux_pattern_suffix_with_context], [194], [198], [206], [547], [562], [569], [282], [linux_pattern_suffix_ignore_case], [183], [191], [195], [573], [588], [594], [307], [linux_word], [163], [170], [177], [375], [389], [397], [229], [linux_word_with_heading], [164], [168], [179], [378], [387], [392], [230], [linux_word_ignore_case], [178], [181], [188], [618], [636], [646], [350], [linux_no_literal], [379], [385], [386], [596], [609], [618], [158], [linux_no_literal_ignore_case], [373], [386], [397], [599], [614], [657], [159], [linux_alternatives], [173], [177], [184], [393], [402], [407], [226], [linux_alternatives_with_heading], [172], [177], [184], [393], [400], [407], [226], [linux_alternatives_ignore_case], [200], [203], [206], [420], [427], [432], [210], [subtitles_literal], [7614], [10099], [12845], [9681], [9931], [10534], [98], [subtitles_literal_ignore_case], [8288], [9027], [9977], [9969], [10276], [11202], [113], [subtitles_alternatives], [7959], [9245], [10024], [10435], [10646], [11088], [115], [subtitles_alternatives_ignore_case], [8973], [9735], [10353], [12594], [12921], [13717], [132], [subtitles_surrounding_words], [8186], [9026], [9742], [9737], [9910], [10160], [109], [subtitles_surrounding_words_ignore_case], [7959], [8795], [9736], [10451], [10740], [11166], [122], [subtitles_no_literal], [24069], [24889], [25574], [27419], [27628], [27981], [111], [subtitles_no_literal_ignore_case], [24592], [25243], [26059], [27501], [27692], [28037], [109], ) Average runtime compared to ripgrep: 198%. #pagebreak(weak: true) == Result from a desktop with an Ryzen 5 5600x and 32Gb ram #table( columns: (6fr, 3fr, 3fr, 1fr), align: center, [], [ripgrep [ms]], [searcher [ms]], [], ) #v(0fr) #table( columns: (6fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr), align: (x, y) => if x > 0 { right } else { left }, [name], [min], [avg], [max], [min], [avg], [max], [%], [literal_linux], [101], [103], [106], [265], [274], [289], [265], [literal_linux_hidden], [107], [115], [127], [283], [292], [301], [252], [linux_literal_ignore_case], [108], [110], [114], [271], [275], [283], [248], [linux_pattern_prefix], [101], [104], [109], [267], [270], [273], [259], [linux_pattern_prefix_with_context], [106], [108], [111], [265], [269], [273], [247], [linux_pattern_prefix_ignore_case], [120], [122], [124], [305], [310], [315], [253], [linux_pattern_suffix], [114], [115], [117], [388], [398], [411], [344], [linux_pattern_suffix_with_context], [126], [129], [133], [416], [430], [448], [332], [linux_pattern_suffix_ignore_case], [124], [127], [129], [425], [437], [452], [343], [linux_word], [102], [105], [109], [262], [264], [267], [251], [linux_word_with_heading], [102], [105], [110], [262], [265], [267], [250], [linux_word_ignore_case], [265], [271], [279], [463], [468], [472], [172], [linux_no_literal], [247], [253], [263], [438], [445], [450], [176], [linux_no_literal_ignore_case], [247], [253], [268], [438], [448], [452], [176], [linux_alternatives], [106], [108], [111], [269], [272], [276], [250], [linux_alternatives_with_heading], [107], [109], [111], [269], [272], [276], [249], [linux_alternatives_ignore_case], [122], [124], [128], [285], [289], [291], [232], [subtitles_literal], [1746], [1765], [1781], [7222], [7494], [7656], [424], [subtitles_literal_ignore_case], [2107], [2131], [2152], [7952], [8055], [8101], [377], [subtitles_alternatives], [2072], [2090], [2112], [8034], [8111], [8171], [387], [subtitles_alternatives_ignore_case], [3678], [3685], [3693], [9659], [9776], [9826], [265], [subtitles_surrounding_words], [1781], [1791], [1799], [7495], [7543], [7640], [421], [subtitles_surrounding_words_ignore_case], [2147], [2154], [2160], [7916], [8065], [8136], [374], [subtitles_no_literal], [18383], [18476], [18579], [24502], [24581], [24719], [133], [subtitles_no_literal_ignore_case], [18380], [18524], [18652], [24298], [24556], [24663], [132], ) Average runtime compared to ripgrep: 272%.
https://github.com/drupol/ipc2023
https://raw.githubusercontent.com/drupol/ipc2023/main/src/ipc2023/intro.typ
typst
#import "imports/preamble.typ": * #focus-slide[ #set text(size:2em, fill: white, font: "Virgil 3 YOFF") #set align(center + horizon) Welcome! #pdfpc.speaker-note(```md Hello everyone, Thanks for being here... for being here during lunch time, double bravo for you! I'm so glad to be here, it's been a while I wanted to make such a talk and I can't wait to start. You know I love the PHP language, I love Nix... and I'm extremely enthousiastict to present my first presentation on those two subjects together. During one hour, you'll be my alpha audience. I guess most of you here knows PHP right? And I also guess you all want to know more about what Nix is... Well, I hope you like stories, because I'm going to start with a story, my story. Don't worry, it's not going to be long, it's just to explain some context. So... how did I end up here, in Munich talking about a piece of software that I didn't even know existed 3 years ago? Today, I will explain what led me to that discovery, how it changed my life, and hopefully how it can change yours too. Let's jump back 10 years ago, in 2013. ```) ] #focus-slide(background-img: image("../../resources/images/IMG_20130527_210513.jpg"))[ #set text(fill: white, font: "Virgil 3 YOFF") #align(top)[ The Drupal era ] #pdfpc.speaker-note(```md This is what I call "the Drupal era". I was employee of a consultancy company, taking care of their intranet running Drupal 7. The picture you see there is genuine, I was in Portland for the DrupalCon. I city I wish to revisit one day. And yeah, I was using Drupal a lot back then. Drupal 7 was the mainstream version, and Drupal 8 was still in the making. It was the good time, and it was fun to use it, it was somehow the "goldenDrupal era"... this is most probably not the same anymore, but OK, this is another subject. At the time, PHP 5.3 was massively used everywhere and no Composer was required to run it. ```) ] #focus-slide(background-img: image("../../resources/images/IMG_20140930_102359.jpg", fit: "cover"))[ #set text(size: 2em, fill: white, font: "Virgil 3 YOFF") #align(bottom)[ Drupal 8 ] #pdfpc.speaker-note(```md Back in Belgium, we are now september 2014... and... Ho my gosh time is passing so quickly... anyway... I was playing with the development version of Drupal 8 on my good old Thinkpad X230 running Gentoo. By looking at the URL, I remember the setup I had for testing various Drupal versions. I created multiple directories within my coding folder, each serving a different version of Drupal. These directories were mapped to a unique Apache virtual host configuration. At the time, PHP 5.6 was just released and Composer was required for installing Drupal 8... The PHP landscape was clearly evolving, challenging us to adapt and learn new ways of doing things. ```) ] #focus-slide(background-img: image("../../resources/images/DSC_0959.jpg", fit: "cover"))[ #set text(size: 2em, fill: white, font: "Virgil 3 YOFF") #align(top)[EASME] #pdfpc.speaker-note(```md During the same year, the first turn in my carreer happened. I was hired as an external consultant by the European Commission, in the EASME agency in Brussels. I was in charge of a huge mostly static Drupal 7 intranet website and a couple of others internal Drupal websites. And during my work there, I've started to get some interestes into automation. I've setup a automated deployment system based on Aegir, a Drupal hosting and deployment system. It was a bit of a pain to setup, but it was working quite well for our needs. I stayed there 3 years, and at the end, I was out of job since most of the things were automated. It was time for me to move on to something else and challenging myself again. ```) ] #focus-slide(background-img: image("../../resources/images/IMG_20180627_132556.jpg", fit: "cover"))[ #set text(size: 2em, fill: white, font: "Virgil 3 YOFF") #align(top)[Digit] #pdfpc.speaker-note(```md In 2017, I had the pleasure to join Digit, the ministry of IT, the European Commission's IT department. There,I became part of a development team focused on the European Commission's Drupal 7 platform. There, I re-discovered the joy of working in a team, making code-reviews,... and the pain of working with a legacy codebase. This was a wonderful time for me, I learned a lot about Drupal, about the European Commission, about the way things are done there. I was moslty driven by the desire to improve the way we were working, make the project more stable and reliable, and automatize most of the things... like... the coding standards! You cannot imagine the time we've spent on fixing coding standards issues... and the time we've spent on arguing on how to fix them! Technologically, we were, if I may say, on the cutting edge! Almost. Using PHP 7 and using Composer for Drupal 7 installations. And, unlike traditional corporate settings, our team had the liberty to use their personal computers for development. This was facilitated by the open-source nature of our work, freeing us from the constraints of using standard-issue corporate machines running Microsoft software. Some colleagues were using Linux, some other Mac, and some other Windows. and this variety of ecosystem created a lot of issues when it comes to deploy the application, or fixing bugs. ```) ] #focus-slide(background-img: image("../../resources/images/IMG_20180416_161227-01.jpg", fit: "cover"))[ #set text(size: 2em, fill: white, font: "Virgil 3 YOFF") #align(bottom + center)[Digit] #pdfpc.speaker-note(```md I don't know if you ever worked with Drupal 7 and with its theming layer... but there were a lot of weird things. So, I decided to publish a Drupal module called "registry on steroids" that was fixing the flaws in the theming registry... as you can see in this picture, my colleague Robert and I were about to release the the version 1.1... And yes, working in that team was working hard and a lot of fun. ```) ] #focus-slide(background-img: image("../../resources/images/IMG_20170922_155142.jpg", fit: "cover"))[ #set text(size: 2em, fill: white, font: "Virgil 3 YOFF") #align(bottom)[Digit] #pdfpc.speaker-note(```md While we were having a lot of fun as you can see on this picture, we also had a lot of issues with the way we were working. Since we were using a lot of different tools, we had different state of mind on how the code should be structured... and we were not always agreeing on the way we should work. This is how I got into functional programming, but this is another story, maybe for another talk! We were spending quite a lot of time on adjusting each other's code to make it work on our own machine. At some point, we decided to create a new platform running Drupal 8, PHP 7.4, and using Composer for everything. Therefore, we decided to also embrace the DevOps culture and to automate as much as possible our workflow... and that means using Docker for pretty much everything. It took me some time to accept that it was the optimal way to work together, and to make sure that we were all working in the same environment... Nevertheless, using Docker for the least thing was quite a pain for me, especially on my good old thinkpad. This new way of working was quite difficult to adopt, I never liked doing everything in container, I always preferred to have a local environment. It was so much faster and easy to use. Then at some point, I got fed up of Drupal 8, maybe mostly because of all these technical issues, I decided to join another team in Digit. It was time for me to say Goodbye to Drupal and to move on to some new horizon... once again. ```) ] #focus-slide(background-img: image("../../resources/images/PXL_20220905_134209654.jpg", fit: "cover"))[ #set text(size: 2em, fill: white, font: "Virgil 3 YOFF") #align(top + center)[Digit] #pdfpc.speaker-note(```md And speaking of horizon, this photo is taken from the cafetaria of the building I'm now working in, ... quite impressive isn't it ?! It's at 100m high... Now when I'm being asked what I do for a living, I just reply: I work in the clouds! I joined the Digit PHP competency center where I'm in charge of helping teams to migrate their applications from ColdFusion to PHP, making sure that their experience with PHP is successful. I quickly notice the same kind of issues, the same "class", type of problems, that I was having in the previous team. Some developers were using Windows, some others Linux, some others Mac. Most of the time none of these environments are not aligned with the rest of the team... and therefore, this create a lot of issues when it comes to use a specific PHP extension (Oracle, I'm looking at you), deploy the application, or fixing bugs. Attempts to fix this issue were made using Ansible, but it was not enough, and in the end, almost nobody uses it. And I was like "There must be a way to fix this gracefuly..." and I started to search for a solution... Today, I'm still working in the same team, and I can say that I have found a solution! It's not perfect, but things are a much better than before... we'll see together how we got there. ```) ] #focus-slide[ #set align(center + horizon) #set par(justify: true) #set text(font: "Virgil 3 YOFF") #uncover("1-")[Hello, my name is *<NAME>*] #uncover("2-")[I'm here to talk about] #uncover("3-")[*Nix*] #set align(right + horizon) #uncover("4-")[#text(size:.3em, font: "Virgil 3 YOFF")[...and a little bit about PHP]] #pdfpc.speaker-note(```md So, hello everyone, I'm <NAME>, I live in Belgium and I work as an external consultant for European Commission since a decade and I'm here to talk about Nix... a piece of software I discovered not so long ago and which is helping me everyday in my life. And yeah, we are going to talk just a little bit of PHP... so don't expect a talk on why classes should be final by default! As a linux user, I was a long time devoted Gentoo user and I began to experience system slowdowns on my laptop. Each update increasingly demanded tedious, time-consuming recompilations. There has been countless nights when I would leave my computer to grinding through the compilation of KDE, Firefox, and the rest. This process was no longer sustainable, and it became clear to me that I needed a faster, more eco-friendly binary packages based distribution. And As I was anxiously awaiting the release of the Thinkpad X13G2 in Belgium, which, spoiler alert, never happened, I decided to explore a tool I've been hearing about since my tribulations with functional programming: Nix. So, I discovered Nix 2 years ago, during the Covid period, in June 2021, it's not that far away! The thing when it comes to Nix, is that you can either use Nix, the tool on your existing operating system... or you can use NixOS, the operating system built around the Nix tool. There are sayings that you can't really use NixOS without using Nix before, and I'm here to tell you that it's not true. I decided to go down to the rabbit hole immediately... I bought a new hard disk drive and gave NixOS a test run. To my surprise, I found myself not wanting to return to my old Gentoo. A companion of 10 years now gathering dust. Rest in peace, little angel. Of course Gentoo is great, but it's nothing to compare to NixOS, NixOS is just pure awesomeness in every aspect. All of this is great... but what is Nix? I guess if you're here, it's to know more about it... and the time has come! The thing is that, explaining Nix to people who never heard of it, or even use it is somehow quite difficult and I underestimated the task... Why? Look at those carefully chosen screenshots... ```) ] #focus-slide(background-color: rgb("#111111"))[ #set align(center + horizon) #set text(size: .2em) #pad(2em)[ #figure( image("../../resources/screenshots/Screenshot_20231019_224304.png"), caption: [ #link("https://main.elk.zone/mathstodon.xyz/@[email protected]/111063172442171910")[https://main.elk.zone/mathstodon.xyz/@[email protected]/111063172442171910] ] ) ] #pdfpc.speaker-note(```md This screenshot from Mastodon... to give you a glimpse on how hard the task to explain nix is. I've got some other examples... ```) ] #focus-slide(background-color: rgb("#111111"))[ #set align(center + horizon) #set text(size: .2em) #pad(2em)[ #figure( image("../../resources/screenshots/Screenshot_20231019_224108.png"), caption: [ #link("https://main.elk.zone/darmstadt.social/@Atemu/111063395928947898")[https://main.elk.zone/darmstadt.social/@Atemu/111063395928947898] ] ) ] #pdfpc.speaker-note(```md And another one here... So don't worry, I'm not going to write a PHD to explain what Nix is or how it works... I'm just going to give you a glimpse of what it is and how, hopefully, it can help you as well. ```) ] #focus-slide(background-color: rgb("#080808"))[ #set align(center + horizon) #set text(size: .2em) #pad(2em)[ #figure( image("../../resources/screenshots/Screenshot_20231005_120226.png"), caption: [ #link("https://twitter.com/matyo91/status/1501500584242860032")[https://twitter.com/matyo91/status/1501500584242860032] ] ) ] #pdfpc.speaker-note(```md Here's a french Symfony developer... ```) ] #focus-slide(background-color: rgb("#313543"))[ #set align(center + horizon) #set text(size: .2em) #figure( image("../../resources/screenshots/Screenshot_20231005_120003.png"), caption: [ #link("https://mastodon.social/@php_discussions/109576203192335392")[https://mastodon.social/@php_discussions/109576203192335392] ] ) #pdfpc.speaker-note(```md Here's a german PHP developer... Fortunately, I'm not the only one advocating Nix in the PHP ecosystem... ```) ] #focus-slide(background-color: rgb("#111111"))[ #set align(center + horizon) #set text(size: .2em) #pad(2em)[ #figure( image("../../resources/screenshots/Screenshot_20231005_213801.png"), caption: [ #link("https://main.elk.zone/mathstodon.xyz/<EMAIL>/111184067773971992")[https://main.elk.zone/mathstodon.xyz/@<EMAIL>@<EMAIL>/111184067773971992] ] ) ] #pdfpc.speaker-note(```md Here's another developer... ```) ] #focus-slide(background-color: rgb("#000000"))[ #set align(center + horizon) #set text(size: .2em) #pad(2em)[ #figure( image("../../resources/screenshots/Screenshot_20231005_113953.png"), caption: [ #link("https://twitter.com/Ocramius/status/1504406934664921089")[https://twitter.com/Ocramius/status/1504406934664921089] ] ) ] #pdfpc.speaker-note(```md There's also <NAME> - Ocramius - advocating for the Nix adoption... I guess you all know him. ```) ] #focus-slide(background-color: rgb("#000000"))[ #set align(center + horizon) #set text(size: .2em) #pad(2em)[ #figure( image("../../resources/screenshots/Screenshot_20231012_224915.png"), caption: [ #link("https://twitter.com/mitchellh/status/1649503702456340483")[https://twitter.com/mitchellh/status/1649503702456340483] ] ) ] #pdfpc.speaker-note(```md Here you can see a message from <NAME>... the creator of Vagrant, Terraform, etc etc... I totally share his views. In 20 years of IT, I could count on a single hand the most impactful technologies that happened in my life... php, git, nix... looks like all the great things are in three letters, isn't it ? ```) ] #focus-slide(background-color: rgb("#000000"))[ #set align(center + horizon) #set text(size: .2em) #pad(2em)[ #figure( image("../../resources/screenshots/Screenshot_20231012_225714.png"), caption: [ #link("https://twitter.com/mitchellh/status/1491102567296040961")[https://twitter.com/mitchellh/status/1491102567296040961] ] ) ] #pdfpc.speaker-note(```md And a last message here still from him. Let's stop here... This intro was here just to show you where I come from and why technologies like Nix are useful and problem solving. From there, I've summarized my needs, in the context of PHP. Typically, a PHP developper need: - The PHP interpreter - A package manager, Composer obviously - A cool command line with contextual information - The freedom to customize its environment - All of this aligned with it's colleagues... Typically, a PHP developper do not need: - Spending too much time learning new tools to setup its develpment environments - Dependencies conflicts - Being told which tool to use to develop Given all of this, let's see how we can leverage Nix to improve the developer experience. Let's unravel all together the mistery of Nix! By the way, this presentation will be available online at some point, it contains many links, especially in the figure captions. I encourage you to visit to learn more about something or to just verify what I'm saying. Oh and this presentation is totally reproducible for anyone, but we'll come to that later ;) ```) ]
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/fletcher/0.4.2/src/layout.typ
typst
Apache License 2.0
#import "utils.typ": * #import "shapes.typ" /// Resolve the sizes of nodes. /// /// Widths and heights that are `auto` are determined by measuring the size of /// the node's label. #let compute-node-sizes(nodes, styles) = nodes.map(node => { // Width and height explicitly given if auto not in node.size { let (width, height) = node.size node.radius = vector-len((width/2, height/2)) node.aspect = width/height // Radius explicitly given } else if node.radius != auto { node.size = (2*node.radius, 2*node.radius) node.aspect = 1 // Width and/or height set to auto } else { // Determine physical size of node content let (width, height) = measure(node.label, styles) let radius = vector-len((width/2, height/2)) // circumcircle node.aspect = if width == 0pt or height == 0pt { 1 } else { width/height } if node.shape == auto { let is-roundish = max(node.aspect, 1/node.aspect) < 1.5 node.shape = if is-roundish { "circle" } else { "rect" } } // Add node inset if radius != 0pt { radius += node.inset } if width != 0pt and height != 0pt { width += 2*node.inset height += 2*node.inset } // If width/height/radius is auto, set to measured width/height/radius node.size = node.size.zip((width, height)) .map(((given, measured)) => map-auto(given, measured)) node.radius = map-auto(node.radius, radius) } if node.shape in (circle, "circle") { node.shape = shapes.circle } if node.shape in (rect, "rect") { node.shape = shapes.rect } node }) /// Convert an array of rects with fractional positions into rects with integral /// positions. /// /// If a rect is centered at a factional position `floor(x) < x < ceil(x)`, it /// will be replaced by two new rects centered at `floor(x)` and `ceil(x)`. The /// total width of the original rect is split across the two new rects according /// two which one is closer. (E.g., if the original rect is at `x = 0.25`, the /// new rect at `x = 0` has 75% the original width and the rect at `x = 1` has /// 25%.) The same splitting procedure is done for `y` positions and heights. /// /// - rects (array of rects): An array of rectangles of the form /// `(center: (x, y), size: (width, height))`. The coordinates `x` and `y` may be /// floats. /// -> array of rects #let expand-fractional-rects(rects) = { let new-rects for axis in (0, 1) { new-rects = () for rect in rects { let coord = rect.center.at(axis) let size = rect.size.at(axis) if calc.fract(coord) == 0 { rect.center.at(axis) = calc.trunc(coord) new-rects.push(rect) } else { rect.center.at(axis) = floor(coord) rect.size.at(axis) = size*(ceil(coord) - coord) new-rects.push(rect) rect.center.at(axis) = ceil(coord) rect.size.at(axis) = size*(coord - floor(coord)) new-rects.push(rect) } } rects = new-rects } new-rects } /// Determine the number, sizes and relative positions of rows and columns in /// the diagram's coordinate grid. /// /// Rows and columns are sized to fit nodes. Coordinates are not required to /// start at the origin, `(0,0)`. #let compute-grid(nodes, edges, options) = { let rects = nodes.map(node => (center: node.pos, size: node.size)) rects = expand-fractional-rects(rects) // all points in diagram that should be spanned by coordinate grid let points = rects.map(r => r.center) points += edges.map(e => e.vertices).join() if points.len() == 0 { points.push((0,0)) } let min-max-int(a) = (calc.floor(calc.min(..a)), calc.ceil(calc.max(..a))) let (x-min, x-max) = min-max-int(points.map(p => p.at(0))) let (y-min, y-max) = min-max-int(points.map(p => p.at(1))) let origin = (x-min, y-min) let bounding-dims = (x-max - x-min + 1, y-max - y-min + 1) // Initialise row and column sizes to minimum size let cell-sizes = zip(options.cell-size, bounding-dims) .map(((min-size, n)) => range(n).map(_ => min-size)) // Expand cells to fit rects for rect in rects { let indices = vector.sub(rect.center, origin) for axis in (0, 1) { cell-sizes.at(axis).at(indices.at(axis)) = max( cell-sizes.at(axis).at(indices.at(axis)), rect.size.at(axis), ) } } // (x: (c1x, c2x, ...), y: ...) let cell-centers = zip(cell-sizes, options.spacing) .map(((sizes, spacing)) => { zip(cumsum(sizes), sizes, range(sizes.len())) .map(((end, size, i)) => end - size/2 + spacing*i) }) let total-size = cell-centers.zip(cell-sizes).map(((centers, sizes)) => { centers.at(-1) + sizes.at(-1)/2 }) assert(options.axes.at(0).axis() != options.axes.at(1).axis(), message: "Axes cannot both be in the same direction; try `(ltr, ttb)`.") let flip = options.axes.map(a => a.axis()) == ("vertical", "horizontal") if flip { options.axes = options.axes.rev() } let scale = ( if options.axes.at(0) == ltr { +1 } else if options.axes.at(0) == rtl { -1 }, if options.axes.at(1) == btt { +1 } else if options.axes.at(1) == ttb { -1 }, ) let get-coord(coord) = { zip(if flip { coord.rev() } else { coord }, cell-centers, origin, scale) .map(((x, c, o, s)) => s*lerp-at(c, x - o)) } ( centers: cell-centers, sizes: cell-sizes, origin: origin, bounding-size: total-size, scale: scale, get-coord: get-coord, ) } /// Convert elastic diagram coordinates in nodes and edges to canvas coordinates /// /// Nodes have a `pos` (elastic coordinates) and `final-pos` (canvas /// coordinates), and edges have `from`, `to`, and `vertices` (all canvas /// coordinates). #let compute-final-coordinates(nodes, edges, grid, options) = ( nodes: nodes.map(node => { node.final-pos = (options.get-coord)(node.pos) node }), edges: edges.map(edge => { edge.final-vertices = edge.vertices.map(options.get-coord) edge }), )
https://github.com/Ombrelin/adv-java
https://raw.githubusercontent.com/Ombrelin/adv-java/master/Slides/1-outils.typ
typst
#import "@preview/polylux:0.3.1": * #import "@preview/sourcerer:0.2.1": code #import themes.clean: * #show: clean-theme.with( logo: image("images/efrei.jpg"), footer: [<NAME>, EFREI Paris], short-title: [EFREI LSI L3 ALSI62-CTP : Java Avancé], color: rgb("#EB6237") ) #title-slide( title: [Java Avancé], subtitle: [Cours 1 : Outillage], authors: ([<NAME>]), date: [19 Janvier 2024], ) #slide(title: [Les outils du module])[ - Plateforme de développement : Machine Virtuelle Java (JVM) - Langage de programmation : Java 21 - Environment de développement intégré : IntelliJ IDEA Community - Système de Gestion de Version : Git et GitLab - Système de build : Gradle ] #new-section-slide("Git") #slide(title: [Qu'est ce que Git ?])[ Système de Gestion de Version : - Versionner le code : suivre précisement les changements - Naviguer entre les versions - Ne pas perdre de changements - Revenir en arrière - Coopération à plusieurs sur le même code ] #slide(title: [Concepts importants])[ - *Commit :* version du code sauvegardée à un instant T. - *Branche :* historiques de commits qui évoluent en parallèle Créer un dépôt local : #code( lang: "Bash", ```bash mkdir dossierPourMonDepot cd dossierPourMonDepot git init ``` ) ] #slide(title: [Base d'un workflow Git])[ - Créer un commits 1. `git add .` : ajouter tous les changements au suivi git 2. `git commit -m "message de commit"` : crée un commit avec les changements trackés - Créer une branche : 1. `git branch nomDeLaBranche` : créer la branche 2. `git checkout nomDeLaBranche` : se positionner sur la branche ] #slide(title: [Fusion])[ Pour appliquer les changement présents sur une branche à une autre : #code( lang: "Bash", ```bash git checkout brancheCible git merge brancheAFusionner ``` ) On appliquer les changement des la branche `brancheAFusionner` sur la branche `brancheCible`. Attention aux conflits ! ] #slide(title: [Dépôt distant])[ #code( lang: "Bash", ```bash git remote add nomLocalDuDepotDistant urlDuDepotDistant ``` ) 1. Sauvegarder son travail en lieu sur 2. Coopérer avec d'autres personnes Intéraction : - `git push nomDelaBranche` : pousser une branche locale vers le dépôt - `git pull nomDelaBranche` : récupérer une branche distante dans son dépôt local ] #slide(title: [Récap des espaces])[ #figure(image("images/espaces-git.png", width: 83%)) ] #slide(title: [Récap du workflow])[ 1. Se positionner sur la branche principale : `git checkout master` 2. Mettre à jour la branche principale : `git pull origin master` 3. Créer une nouvelle branche à partir de la branche principale : `git branch maFeature` 4. Se positionner sur la nouvelle branche : `git checkout maFeature` 5. Faire des changements dans le code 6. Ajouter les changements à git : `git add .` 7. Créer un nouveau commit avec les changements : `git commit -m "message de commit"` 8. Pousser les changements : `git push origin maFeature` 9. Retourner sur master : `git checkout master` 10. Fusionner la branche de feature : `git merge maFeature` ] #focus-slide(background: rgb("#EB6237"))[ Des questions ? ] #new-section-slide("Gradle") #slide(title: [Qu'est ce que Gradle ?])[ - Outil de build - Structuer le projet - Décrire comment le compiler, packager, exécuter, tester ] #slide(title: [Structure d'un projet Gradle])[ #code( lang: "Bash", ```bash ├── settings.gradle └── app ├── build.gradle └── src ├── main │ └── java │ └── demo │ └── App.java └── test └── java └── demo └── AppTest.java ``` ) ] #slide(title: [`settings.gradle`])[ #code( lang: "Groovy", ```Groovy rootProject.name = 'mon-projet' include('app') ``` ) ] #slide(title: [`app/build.gradle`])[ #code( lang: "Groovy", ```Groovy plugins { id 'application' } repositories { mavenCentral() } application { mainClass = 'fr.arsenelapostolet.App' } dependencies { testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' implementation 'com.google.guava:guava:31.1-jre' } java { toolchain { languageVersion = JavaLanguageVersion.of(21) } } tasks.named('test') { useJUnitPlatform() } ``` ) ] #slide(title: [Commandes de base])[ - Pour exécuter l'application : `./gradlew run` - Pour exécuter les tests : `./gradlew test` Sur windows : `./gradlew` est remplacé par `./gradlew.bat` ] #focus-slide(background: rgb("#EB6237"))[ Des questions ? ]
https://github.com/emfeltham/emf-cv
https://raw.githubusercontent.com/emfeltham/emf-cv/main/main.typ
typst
#import "simplecv.typ": template, education_entry, work_entry, skill_entry // Change the theme color of the cv. #let color = rgb("#00356b") // Change to your name. #let name = "<NAME>" // Change the shown contact data. You can also change the order of the elements so that they will show up in a different order. Currently, only these five elements are available with icons, but you can add new ones by editing the template. #let contact_data = ( ( "service": "email", "display": "<EMAIL>", "link": "mailto://<EMAIL>" ), ( "service": "orcid", "display": "0000-0001-8080-7119", "link": "https://orcid.org/0000-0001-8080-7119" ), ( "service": "github", "display": "emfeltham", "link": "https://github.com/emfeltham" ), ( "service": "website", "display": "emfeltham.github.io", "link": "https://emfeltham.github.io" ), // ( // "service": "phone", // "display": "+1 123 456 789", // "link": "tel:+1 123 456 789" // ), ) #show: doc => template(name, contact_data, color, doc) // Starting from here, you can add as much content as you want. This represents the main content of the cv. = Employment #work_entry("Postdoctoral Research Scholar", [Data Science Institute, Columbia University], start_date: "Sept. 2024", end_date: "", tasks: ([Hosts: Drs. <NAME> and <NAME>],)) #work_entry("Postdoctoral Associate", [Yale Institute for Network Science and Department of Sociology, Yale University], start_date: "June 2023", end_date: "Aug. 2024", ) = Education #education_entry("Sociology", "Yale University (with Distinction)", degree_title: "Ph.D.,", end_date: "May 2023", description: [ Dissertation title: "Cognizing Social Networks" \ Dissertation committee: Drs. <NAME> (chair), <NAME>, <NAME>, Ifat Levy ], location: "New Haven, CT") #education_entry("Statistics", "Yale University", degree_title: "M.A.,", end_date: "2018", description: [], location: "New Haven, CT") #education_entry("Philosophy; B.A., Economics", "University of Massachusetts Amherst", degree_title: "B.A.,", end_date: "2013", description: [_magna cum laude_, _Phi Beta Kappa_], location: "Amherst, MA") = Research interests #grid( columns: (30fr, 6fr), [Social theory, social networks, mathematical sociology, computational social science, social cognition, social psychology, political sociology], //causal inference statistical methods, ) = Publications *<NAME>*, <NAME>, and <NAME>. "Humans possess systematically distorted cognitive representations of their social networks" (revise and resubmit at _Nature Human Behaviour_). *<NAME>*, <NAME>, <NAME>, <NAME>. (2023). "Mass gatherings for political expression had no discernible association with the local course of the COVID-19 pandemic in the USA in 2020 and 2021". _Nature Human Behavior_. #link("https://doi.org/10.1038/s41562-023-01654-1") <NAME> and *<NAME>*. (2021). "Structure". In #link("https://www.e-elgar.com/shop/usd/research-handbook-on-analytical-sociology-9781789906844.html")[_Research Handbook on Analytical Sociology_]. Cheltenham, UK: Edward Elgar Publishing. <NAME> and *<NAME>*. (2020). "Historical Network Research". In _Oxford Handbook of Social Networks_. New York: Oxford UP. #link("https://doi.org/10.1093/oxfordhb/9780190251765.001.0001") <NAME>, <NAME>, *<NAME>*, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>. (2019). "Neural computations of threat in the aftermath of combat trauma". _Nature Neuroscience_ 22, 470–476. #link("https://doi.org/10.1038/s41593-018-0315-x") = Working papers *<NAME>* and <NAME>. "Expecting Homophily". *<NAME>*, <NAME>, and <NAME>. "Sampling Cognitive Social Structures". *<NAME>*. "The Cognition of Network Relations and Categories". *<NAME>* and <NAME>. "The Networked Climate Game". *<NAME>* and <NAME>. "Risk Attitudes and Network Structure in Honduras". *<NAME>*. "Identity and Polarization". <NAME>, *<NAME>*, <NAME>. "Revolutions _in silico_". = Book "Cognizing social networks" (working title). Manuscript in preparation. - Book proposal under review = Other writing *<NAME>* and <NAME>. (2023). "Rapid research with a pandemic bearing down: Studying the impact of mass gatherings on the course of COVID-19". *Springer Nature Communities*. (Invited contribution to "Behind the Paper" series for the Springer Nature Social Sciences online community.) *<NAME>* and <NAME>. (2020). "Voting In The 2020 Primaries Didn’t Worsen The COVID-19 Pandemic". *FiveThirtyEight*. = Honors and awards #work_entry(link("https://sociology.yale.edu/news/eric-martin-feltham-2024-winner-yale-sociology-departments-marvin-b-sussman-dissertation-prize")[Sussman Prize for best dissertation in the past two years], "Yale Department of Sociology, New Haven, CT", end_date: "2024", tasks: ()) #work_entry("Commonwealth Honors College Scholar with Greatest Distinction", [University of Massachusetts Amherst, Amherst, MA], end_date: "2013", tasks: ( [Awarded based on thesis quality and GPA], ) ) = Grants #work_entry("National Institutes of Health, The National Institute on Aging and the Office of Behavioral and Social Sciences Research", [Research Grant (R-01), "Characterizing Individuals' Cognitive Maps of their Village Social Networks"], end_date: "2022", tasks: ( [Award: \$3,226,809 (over 4 years)], [PI: Dr. <NAME>], [Role: Researcher], ) ) #work_entry("<NAME> Johnson Foundation", ["Assessing the Hazard of Elections During the COVID-19 Pandemic"], end_date: "2020", tasks: ( [Award: \$350,000], [PI: Dr. <NAME>], [Role: Researcher], ) ) // #work_entry("U.S. Fulbright Research Semi-Finalist", [], end_date: "2016", tasks: ( // [Proposal to research economic and social decision-making], // ) // ) // #work_entry([#link("https://www.cmu.edu/dietrich/philosophy/undergraduate/summer-school/index.html")[Summer School in Logic and Formal Epistemology]], [Carnegie Mellon University], end_date: "2015", tasks: ( // [Admitted with full-funding to competitive NSF-funded program], // [Took advanced courses in topology, modal logic, and the applications of decision theory for formal epistemology], // ) // ) // #work_entry([#link("https://www.nhlbi.nih.gov/grants-and-training/summer-institute-biostatistics")[Summer Institute for Training in Biostatistics]], [Emory University], end_date: "2014", tasks: ( // [Admitted with full-funding to competitive NIH-funded program], // [Took introductory graduate level Biostatistics courses], // [Presented case studies based on statistical analysis], // ) // ) = Research experience #work_entry("Graduate Researcher", "Yale Institute for Network Science and Human Nature Lab, New Haven, CT", start_date: "2016", end_date: "2023", tasks: ( [Designed and led large scale data collection and analysis efforts on individuals' perceptions of social network structure in 82 villages in rural Honduras], [Developed sampling method for cognitive social structures research design], [Conducted fieldwork in rural Honduras to support data collection and analysis effort for thesis project], [Developed generalized difference-in-differences methodology to estimate the impact of large-scale political gatherings on the spread of COVID-19 in the USA], ) ) #work_entry("Research Fellow", "Dr. <NAME>, Yale University, New Haven, CT", end_date: "2019", tasks: ( [Analyzed historical social network data consisting of English economic manuscript writers from the 18th century], [Applied topic modeling to uncover trends in the economic literature over a roughly 200-year period], ) ) #work_entry("Graduate Researcher", "Drs. <NAME>, <NAME>, <NAME>, University of Chicago, Chicago, IL", end_date: "2018", tasks: ( [Part of a team on a grant "Social MIND: Social Machine Intelligence for Novel Discovery"], ) ) #work_entry("Research Assistant", "Levy and Harpaz-Rotem Labs, Yale University School of Medicine, New Haven, CT", start_date: "2014", end_date: "2016", tasks: ( [Independently performed fear conditioning experiments with human participants in behavioral and MRI settings], [Preprocessed and analyzed fMRI data using BrainVoyager software], ) ) #work_entry("Research Assistant", "Schiller Affective Neuroscience Lab, Mount Sinai Icahn School of Medicine, New York, NY", end_date: "2014", tasks: ( [Independently performed human subject trials investigating the effects of a pharmacological agent on memory formation and persistence], ) ) #work_entry("Undergraduate Honors Thesis", "University of Massachusetts Amherst Commonwealth Honors College, Amherst, MA", end_date: "2013", tasks: ( [Title: “Unconscious Attention? Inattentional Consciousness? Examining the Relationship Between Attention and Phenomenal Consciousness”], [Committee: Drs. <NAME> and <NAME>] ) ) = Software #link("https://github.com/human-nature-lab/TSCSMethods.jl")[TSCSMethods.jl] (sole author) - Performs non-parametric generalized differences-in-differences estimation, with covariate matching #link("https://github.com/human-nature-lab/SamplingPerceivedNetworks.jl")[SamplingPerceivedNetworks.jl] (sole author) - Implements a sampling procedure for "cognitive social structures" data collection #link("https://github.com/emfeltham/Typst.jl")[Typst.jl] (sole author) - Implements an interface from the Julia language to the mark-up language Typst for academic writing #link("https://github.com/JuliaGraphs/GraphDataFrameBridge.jl")[GraphDataFrameBridge.jl] (contributor) - Contributed functions to process network data = Teaching #work_entry([Yale College, New Haven, CT], "Teaching Fellow", start_date: "Jan. 2023", end_date: "May 2023", tasks: ( [Course: Sociology of Crime and Deviance SOCY 141b], ) ) #work_entry([Yale College, New Haven, CT], "Teaching Fellow", start_date: "Sep. 2022", end_date: "Dec. 2022", tasks: ( [Course: Health of the Public SOCY 126a], ) ) #work_entry([Yale College, New Haven, CT], "Teaching Fellow", start_date: "Jan. 2022", end_date: "May 2022", tasks: ( [Course: Topics in Contemporary Social Theory SOCY 152b], ) ) #work_entry([Yale College, New Haven, CT], "Teaching Fellow", start_date: "Sep. 2021", end_date: "Dec. 2021", tasks: ( [Course: Sex and Gender in Society SOCY 134a], ) ) #work_entry([Yale College, New Haven, CT], "Teaching Fellow", start_date: "Jan. 2020", end_date: "May 2020", tasks: ( [Course: Health of the Public SOCY 126b], ) ) #work_entry([Yale College, New Haven, CT], "Teaching Fellow", start_date: "Sep. 2019", end_date: "Dec. 2019", tasks: ( [Course: Foundations of Modern Social Theory SOCY 151a], ) ) #work_entry([Yale College, New Haven, CT], "Teaching Fellow", start_date: "Jan. 2019", end_date: "May 2019", tasks: ( [Course: Social Networks and Society SOCY 167b], ) ) #work_entry([Yale College, New Haven, CT], "Teaching Fellow", start_date: "Sep. 2018", end_date: "Dec. 2018", tasks: ( [Course: Computers, Networks and Society SOCY 133a], ) ) = Invited talks *<NAME>*. "Cognizing social networks". #link("https://www.asanet.org/annual-meeting/")[Mathematical and Computational Methods in Social Psychology (Co-sponsored by Sections on Social Psychology and Mathematical Sociology)], American Sociological Association, Montréal, Québec, August 2024 *<NAME>*. "Cognizing social networks". #link("https://sn.ethz.ch/dualityat50.html")[Duality@50: Making progress and looking forward], ETH Zürich, Ascona, Switzerland, April 2024 *<NAME>*. "Cognizing social networks". University of Iowa, Iowa City, IA, Nov. 2023 *<NAME>*. "Cognizing social networks". Implementation and Dissemination Science Workshop. Copán, Honduras, June 2023 *<NAME>*. "Modeling the Effect of Identity on Polarization". Center for Empirical Research on Stratification and Inequality, Yale University, New Haven, CT, Jan. 2019 *<NAME>*. “Experiments on Observational Learning”. Yale Institute for Network Science, New Haven, CT, Aug. 2018 <NAME>, <NAME>, <NAME>, *<NAME>*, <NAME>, <NAME>, <NAME>. "Cortical thickness and volume of the right posterior parietal cortex predict individual learning rate in healthy adults". Society for Neuroscience, San Diego, CA, 2018 *<NAME>*. "Using Tools from Causal Inference to Reconstruct Simulated Social Data". Defense Advanced Research Projects Agency, Alexandria, VA, 2018 = Mentoring <NAME> (Computer Science and Psychology, Yale College 2027) <NAME> (Statistics and Data Science, PhD Student) <NAME> (Cognitive Science, Yale College 2025) <NAME> (Sociology, Yale College 2025) <NAME> (Economics and Mathematics, Yale College 2024) <NAME> (Cognitive Science, Yale College 2024) <NAME> (Economics, Yale College 2022) = Professional service Reviewer, *Risk Analysis* (2022 Impact Factor: 3.8) Reviewer, *Policy Analysis* (2022 Impact Factor: 2.2) Reviewer, *Yale Undergraduate Research Journal* = Skills // Ratings won't be displayed in this template. #skill_entry("Languages", ( "Julia", "R", "MATLAB", "Python", "Spanish (basic)", "French (basic)" ) ) == Selected coursework Data Analysis, Probability Theory, Theory of Statistics, Multivariate Statistical Analysis, Linear Models, Stochastic Processes, Computational Tools for Data Science, Research Design & Causal Inference, Social Network Analysis, Research Topics in Human Nature and Social Networks, Topics in Biosocial Science, The Microeconomics of Coordination and Conflict = Advocacy #work_entry("Campaign Coordinator", "Students for a Just and Stable Future, Boston, MA", start_date: "2010", end_date: "2011", tasks: ( [Spoke at public events to represent the organization], [Coordinated a campaign with community members and college students from across Massachusetts], [Worked on climate policy for MA state legislation], ) ) #work_entry("Team Leader", "Better Future Project, Boston, MA", start_date: "June 2010", end_date: "Aug. 2011", tasks: ( [Led a team of four members and coordinated their roles relating to media, events, and housing], [Organized events discussing the impacts of economic and environmental policy] ) ) = References + Dr. <NAME>, Sterling Professor of Social and Natural Science, Yale University - <EMAIL> + Dr. <NAME>, Professor of Sociology and (by courtesy) Management, Yale University - <EMAIL> + Dr. <NAME>, Associate Professor of Biostatistics, Yale School of Public Health, Yale University - <EMAIL> // + Dr. <NAME>, Associate Professor of Comparative Medicine, Neuroscience, and Psychology, Yale School of Medicine, Yale University
https://github.com/jamesrswift/musicaux
https://raw.githubusercontent.com/jamesrswift/musicaux/main/src/lib.typ
typst
#import "symbols.typ": symbols #let recursive-render(..body, ctx) = { let body = if body != none {body} else { () } /*for cmd in body.pos() { assert( type(cmd) in (dictionary, array) and "type" in cmd, message: "Expected plot sub-command in notation body, got " + repr(cmd)) }*/ for i in range(body.pos().len()) { if "prepare" in body.pos().at(i) { body.pos().at(i) = (body.pos().at(i).prepare)(body.pos().at(i), ctx) } } for cmd in body.pos(){ let content = none // Sub commands if ( "recurse" in cmd ){ content = recursive-render(..cmd.recurse, ctx) } else if "draw" in cmd { content = (cmd.draw)(cmd, ctx) } if ( content != none ){ style( (styles) => { let size = measure(content, styles) let ctx = (..ctx, size: size) if "sized-pre-draw" in cmd {recursive-render(..(cmd.sized-pre-draw)(cmd, ctx), ctx)} content if "sized-post-draw" in cmd {recursive-render(..(cmd.sized-post-draw)(cmd, ctx), ctx)} if "post-draw" in cmd {(cmd.post-draw)(cmd, ctx)} }) } } } #let notation(body, ctx: (:), stave: true) = { assert( type(body) in (array,), message: "Invalid notation!") set text(font: "Noto Music", size: 20pt) block( if (stave){ text(tracking: -0.1em)[𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚] } +place(recursive-render(..body, ctx)) ) } #let group(content) = { set text(font: "Noto Music", size: 20pt) style( (styles) => { let size = measure(content, styles) block( content + place( move( dy: -size.height * 75%, dx: -0.35em, scale( y: ((size.height.pt() * 1pt) / 20pt) * 100%, origin: left+top, symbols.brace ) ) ) ) }) } #let aligned(staves: 2, v-space: 1em, ctx: (:), ..content) = { assert( calc.rem(content.pos().len(), staves) == 0 ) set text(font: "Noto Music", size: 20pt) style( styles => { let render = ([],) * staves set text(font: "Noto Music", size: 20pt) for segment in range(0, content.pos().len() - 1, step: staves) { let inner-render = ([],) * staves for inner-segment in range(0, staves) { inner-render.at(inner-segment) += recursive-render(..content.pos().at( segment + inner-segment ), ctx) } // Measure segments let width = calc.max( ..inner-render.map(it=>{return measure(it, styles).width})) for inner-segment in range(0, staves) { render.at(inner-segment) += box( width: width, inner-render.at(inner-segment) ) } } group( render.map( (it) => { block( text(tracking: -0.1em)[𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚𝄚] + place(it) ) } ).join(v(v-space)) ) //v(v-space) }) } #import "cmd.typ" #import "template.typ": score
https://github.com/cu-e/typst-study
https://raw.githubusercontent.com/cu-e/typst-study/main/first.typ
typst
= Тестовая запись Это тестовая запись, учусь писать на typst + Первое + Второе + Третье + Четвертое + Раскрытое - цаца Вот привкольная картинка @картинка1 Обязательно посмотрите на нее #figure( image("./image.png", width: 8cm), caption: [*изображение №1*] )<картинка1> == Математика Вот пример записи $Q = p A v + C$ \ А если нужна запись с текстом то $Q = r + "такой текст"$ \ $pi = 3.14$ \ $circle RR ZZ | x "this natural"$ #let x = 5; \ $#x gt.eq.not 17$ $sum_(j = 5) ^ "n" k = 1 + ... + n$ \ \ $(n(n+1)) / 2$ $mat(12,12,12; 12,12; 122,1222,12)$ \ $lim_x$ \ $grave(a), arrow(a), tilde(a)$ \ $underbrace("wdqd", "там сверху что то есть") emptyset infinity $
https://github.com/DawnEver/ieee-conference-typst-template
https://raw.githubusercontent.com/DawnEver/ieee-conference-typst-template/main/main.typ
typst
MIT License
#import "template.typ": * #show: ieee_conference.with( title: "Your Title", abstract: [ #lorem(30) ], authors: ( ( name: "Name", department: [Dept of Affiliation], organization: [Affiliation], location: [City, Country], email: "<EMAIL>" ), ( name: "Name", department: [Dept of Affiliation], organization: [Affiliation], location: [City, Country], email: "<EMAIL>" ), ), index-terms: ("A", "B", "C", "D"), bibliography-file: "refs.bib", ) = Introduction #lorem(30) Citation example of reference papers#cite(<example>) = Theoretical Framework #lorem(30) Citation example of Fig @a. #grid( columns: (auto, auto), rows: (auto, auto), gutter: 1pt, [ #figure( image("./img/image.png"), caption: [1biudwi8d10do12h-1dj], )<a> ], [ #figure( image("./img/image.png"), caption: [1biudwi8d10do12h-1dj], )<b> ], [ #figure( image("./img/image.png"), caption: [1biudwi8d10do12h-1dj], )<c> ], [ #figure( image("./img/image.png"), caption: [1biudwi8d10do12h-1dj], )<d> ], )\ #lorem(30) = Methodological Framework #figure( table( columns: (auto, auto, auto,auto, auto, auto), inset: 3pt, align: horizon, [*Parameter*], [*Value*], [*Unit*],[*Parameter*], [*Value*], [*Unit*], [#lorem(2)],[#lorem(2)],[], [#lorem(2)],[#lorem(2)],[], [#lorem(2)],[#lorem(2)],[], [#lorem(2)],[#lorem(2)],[mm], [#lorem(2)],[#lorem(2)],[mm], ), caption: [#lorem(10)], )<baseline_motor_parameter>\ #lorem(30) = Result Analysis #lorem(30) = Recommendations and Conclusions #lorem(30)
https://github.com/Dicarbene/note-typst
https://raw.githubusercontent.com/Dicarbene/note-typst/master/utils/algo.typ
typst
MIT License
// counter to track the number of algo and code elements // used as an id when accessing: // _algo-comment-lists // _algo-page-break-lines #let _algo-id-ckey = "_algo-id" // counter to track the current indent level in an algo element #let _algo-indent-ckey = "_algo-indent" // counter to track the number of lines in an algo element #let _algo-line-ckey = "_algo-line" // state value to track whether the current context is an algo element #let _algo-in-algo-context = state("_algo-in-algo-context", false) // state value to mark the page that each line of an // algo or code element appears on #let _algo-current-page = state("_algo-current-page", 1) // state value for storing algo comments // dictionary that maps algo ids (as strings) to a dictionary that maps // line indexes (as strings) to the comment appearing on that line #let _algo-comment-lists = state("_algo-comment-lists", (:)) // state value for storing pagebreak occurences in algo or code elements // dictionary that maps algo/code ids (as strings) to a list of integers, // where each integer denotes a 0-indexed line that appears immediately // after a page break #let _algo-pagebreak-line-indexes = state("_algo-pagebreak-line-indexes", (:)) // list of default keywords that will be highlighted by strong-keywords #let _algo-default-keywords = ( "if", "else", "then", "while", "for", "do", ":", "end", "and", "or", "not", "in", "to", "down", "let", "return", "goto", ) // Get the thickness of a stroke. // Credit to PgBiel on GitHub. #let _stroke-thickness(stroke) = { if type(stroke) in ("length", "relative length") { stroke } else if type(stroke) == "color" { 1pt } else if type(stroke) == "stroke" { let r = regex("^\\d+(?:em|pt|cm|in|%)") let s = repr(stroke).find(r) if s == none { 1pt } else { eval(s) } } else if type(stroke) == "dictionary" and "thickness" in stroke { stroke.thickness } else { 1pt } } // Given data about a line in an algo or code, creates the // indent guides that should appear on that line. // // Parameters: // stroke: Stroke for drawing indent guides. // indent-level: The indent level on the given line. // indent-size: The length of a single indent. // content-height: The height of the content on the given line. // block-inset: The inset of the block containing all the lines. // Used when determining the length of an indent guide that appears // on the top or bottom of the block. // row-gutter: The gap between lines. // Used when determining the length of an indent guide that appears // next to other lines. // is-first-line: Whether the given line is the first line in the block. // is-last-line: Whether the given line is the last line in the block. // If so, the length of the indent guide will depend on block-inset. // is-before-page-break: Whether the given line is just before a page break. // If so, the length of the indent guide will depend on block-inset. // is-after-page-break. Whether the given line is just after a page break. // If so, the length of the indent guide will depend on block-inset. #let _indent-guides( stroke, indent-level, indent-size, content-height, block-inset, row-gutter, is-first-line, is-last-line, is-before-pagebreak, is-after-pagebreak, ) = { let stroke-width = _stroke-thickness(stroke) style(styles => { // converting input parameters to absolute lengths let content-height-pt = measure( rect(width: content-height), styles ).width let inset-pt = measure( rect(width: block-inset), styles ).width let row-gutter-pt = measure( rect(width: row-gutter), styles ).width // heuristically determine the height of the containing table cell let text-height = measure( [ABCDEFGHIJKLMNOPQRSTUVWXYZ], styles ).height let cell-height = calc.max(content-height-pt, text-height) // lines are drawn relative to the top left of the bounding box for text // backset determines how far up the starting point should be moved let backset = if is-first-line { 0pt } else if is-after-pagebreak { calc.min(inset-pt, row-gutter-pt) / 2 } else { row-gutter-pt / 2 } // determine how far the line should extend let stroke-length = backset + cell-height + ( if is-last-line { calc.min(inset-pt / 2, cell-height / 4) } else if is-before-pagebreak { calc.min(inset-pt, row-gutter-pt) / 2 } else { row-gutter-pt / 2 } ) // draw the indent guide for each indent level on the given line for j in range(indent-level) { place( dx: indent-size * j + stroke-width / 2 + 0.5pt, dy: -backset, line( length: stroke-length, angle: 90deg, stroke: stroke ) ) } }) } // Creates the indent guides for a given line while updating relevant state. // Updates state for: // _algo-current-page // _algo-pagebreak-line-indexes // // Parameters: // indent-guides: Stroke for drawing indent guides. // content: The content that appears on the given line. // line-index: The 0-based index of the given line. // num-lines: The total number of lines in the current algo/code element. // indent-level: The indent level at the given line. // indent-size: The indent size used in the current algo/code element. // block-inset: The inset of the current algo/code element. // row-gutter: The row-gutter of the current algo/code element. #let _build-indent-guides( indent-guides, content, line-index, num-lines, indent-level, indent-size, block-inset, row-gutter ) = { locate(loc => style(styles => { let curr-page = loc.page() let prev-page = _algo-current-page.at(loc) let id-str = str(counter(_algo-id-ckey).at(loc).at(0)) let pagebreak-index-lists = _algo-pagebreak-line-indexes.final(loc) let content-height = measure(content, styles).height let is-first-line = line-index == 0 let is-last-line = line-index == num-lines - 1 let is-before-pagebreak = ( id-str in pagebreak-index-lists and pagebreak-index-lists.at(id-str).contains(line-index + 1) ) let is-after-pagebreak = prev-page != curr-page // display indent guides at the current line _indent-guides( indent-guides, indent-level, indent-size, content-height, block-inset, row-gutter, is-first-line, is-last-line, is-before-pagebreak, is-after-pagebreak, ) // state updates if is-after-pagebreak { // update pagebreak-lists to include the current line index _algo-pagebreak-line-indexes.update(index-lists => { let indexes = if id-str in index-lists { index-lists.at(id-str) } else { () } indexes.push(line-index) index-lists.insert(id-str, indexes) index-lists }) } _algo-current-page.update(curr-page) })) } // Asserts that the current context is an algo element. // Returns the provided message if the assertion fails. #let _assert-in-algo(message) = { _algo-in-algo-context.display(is-in-algo => { assert(is-in-algo, message: message) }) } // Increases indent in an algo element. // All uses of #i within a line will be // applied to the next line. #let i = { _assert-in-algo("cannot use #i outside an algo element") counter(_algo-indent-ckey).step() } // Decreases indent in an algo element. // All uses of #d within a line will be // applied to the next line. #let d = { _assert-in-algo("cannot use #d outside an algo element") counter(_algo-indent-ckey).update(n => { assert(n - 1 >= 0, message: "dedented too much") n - 1 }) } // Adds a comment to a line in an algo body. // // Parameters: // body: Comment content. #let comment(body) = { _assert-in-algo("cannot use #comment outside an algo element") locate(loc => { let id-str = str(counter(_algo-id-ckey).at(loc).at(0)) let line-index-str = str(counter(_algo-line-ckey).at(loc).at(0)) _algo-comment-lists.update(comment-lists => { let comments = if id-str in comment-lists { comment-lists.at(id-str) } else { (:) } let ongoing-comment = if line-index-str in comments { comments.at(line-index-str) } else { [] } let comment-content = ongoing-comment + body comments.insert(line-index-str, comment-content) comment-lists.insert(id-str, comments) comment-lists }) }) } // Displays an algorithm in a block element. // // Parameters: // body: Algorithm content. // title: Algorithm title. // Parameters: Array of parameters. // line-numbers: Whether to have line numbers. // strong-keywords: Whether to have bold keywords. // keywords: List of terms to receive strong emphasis if // strong-keywords is true. // comment-prefix: Content to prepend comments with. // comment-color: Font color for comments. // indent-size: Size of line indentations. // indent-guides: Stroke for indent guides. // row-gutter: Space between lines. // column-gutter: Space between line numbers and text. // inset: Inner padding. // fill: Fill color. // stroke: Border stroke. #let algo( body, title: none, parameters: (), line-numbers: true, strong-keywords: false, keywords: _algo-default-keywords, comment-prefix: "// ", comment-color: rgb(45%, 45%, 45%), indent-size: 20pt, indent-guides: none, row-gutter: 10pt, column-gutter: 10pt, inset: 10pt, fill: rgb(98%, 98%, 98%), stroke: 1pt + rgb(50%, 50%, 50%) ) = { counter(_algo-id-ckey).step() counter(_algo-line-ckey).update(0) counter(_algo-indent-ckey).update(0) _algo-in-algo-context.update(true) locate( loc => _algo-current-page.update(loc.page()) ) // convert keywords to content values keywords = keywords.map(e => { if type(e) == "string" { [#e] } else { e } }) // concatenate consecutive non-whitespace elements // i.e. just combine everything that definitely aren't on separate lines let text-and-whitespaces = { let joined-children = () let temp = [] for child in body.children { if ( child == [ ] or child == linebreak() or child == parbreak() ){ if temp != [] { joined-children.push(temp) temp = [] } joined-children.push(child) } else { temp += child } } if temp != [] { joined-children.push(temp) } joined-children } // filter out non-meaningful whitespace elements let text-and-breaks = text-and-whitespaces.filter( elem => elem != [ ] and elem != parbreak() ) // handling meaningful whitespace // make final list of empty and non-empty lines let lines = { let joined-lines = () let line-parts = [] let num-linebreaks = 0 for line in text-and-breaks { if line == linebreak() { if line-parts != [] { joined-lines.push(line-parts) line-parts = [] } num-linebreaks += 1 if num-linebreaks > 1 { joined-lines.push([]) } } else { line-parts += [#line ] num-linebreaks = 0 } } if line-parts != [] { joined-lines.push(line-parts) } joined-lines } // build text, comment lists, and indent-guides let algo-steps = () for (i, line) in lines.enumerate() { let formatted-line = { // bold keywords show regex("\S+"): it => { if strong-keywords and it in keywords { strong(it) } else { it } } counter(_algo-indent-ckey).display(indent-level => { if indent-guides != none { _build-indent-guides( indent-guides, line, i, lines.len(), indent-level, indent-size, inset, row-gutter ) } pad( left: indent-size * indent-level, line ) }) counter(_algo-line-ckey).step() } algo-steps.push(formatted-line) } // build algorithm header let algo-header = { set align(left) if title != none { set text(1.1em) if type(title) == "string" { underline(smallcaps(title)) } else { title } if parameters.len() == 0 { $()$ } } if parameters != () { set text(1.1em) $($ for (i, param) in parameters.enumerate() { if type(param) == "string" { math.italic(param) } else { param } if i < parameters.len() - 1 { [, ] } } $)$ } if title != none or parameters != () { [:] } } // build table let algo-table = locate(loc => { let id-str = str(counter(_algo-id-ckey).at(loc).at(0)) let comment-lists = _algo-comment-lists.final(loc) let has-comments = comment-lists.keys().contains(id-str) let comment-contents = if has-comments { let comments = comment-lists.at(id-str) range(algo-steps.len()).map(i => { let index-str = str(i) if index-str in comments { comments.at(index-str) } else { none } }) } else { none } let num-columns = 1 + int(line-numbers) + int(has-comments) let align = { let alignments = () if line-numbers { alignments.push(right + horizon) } alignments.push(left) if has-comments { alignments.push(left + horizon) } (x, _) => alignments.at(x) } let table-data = () for (i, line) in algo-steps.enumerate() { if line-numbers { let line-number = i + 1 table-data.push(str(line-number)) } table-data.push(line) if has-comments { if comment-contents.at(i) == none { table-data.push([]) } else { table-data.push({ set text(fill: comment-color) comment-prefix comment-contents.at(i) }) } } } table( columns: num-columns, column-gutter: column-gutter, row-gutter: row-gutter, align: align, stroke: none, inset: 0pt, ..table-data ) }) // display content set par(justify: false) align(center, block( width: auto, height: auto, fill: fill, stroke: stroke, inset: inset, outset: 0pt, breakable: true )[ #algo-header #v(weak: true, row-gutter) #align(left, algo-table) ]) _algo-in-algo-context.update(false) } // Displays code in a block element. // Credit to Dherse on GitHub for the code // to display raw text with line numbers. // // Parameters: // body: Raw text. // line-numbers. Whether to have line numbers. // indent-guides: Stroke for indent guides. // tab-size: Amount of spaces that should be considered an indent. // Set to none if you intend to use tab characters. // row-gutter: Space between lines. // column-gutter: Space between line numbers and text. // inset: Inner padding. // fill: Fill color. // stroke: Border stroke. #let code( body, line-numbers: true, indent-guides: none, tab-size: 2, row-gutter: 10pt, column-gutter: 10pt, inset: 10pt, fill: rgb(98%, 98%, 98%), stroke: 1pt + rgb(50%, 50%, 50%) ) = { counter(_algo-id-ckey).step() locate( loc => _algo-current-page.update(loc.page()) ) let table-data = () let raw-children = body.children.filter(e => e.func() == raw) let lines-by-child = raw-children.map(e => e.text.split("\n")) let num-lines = lines-by-child.map(e => e.len()).sum() let line-index = 0 for (i, lines) in lines-by-child.enumerate() { for line in lines { if line-numbers { table-data.push(str(line-index + 1)) } let content = { let raw-line = raw(line, lang: raw-children.at(i).lang) if indent-guides != none { style(styles => { let (indent-level, indent-size) = if tab-size == none { let whitespace = line.match(regex("^(\t*).*$")) .at("captures") .at(0) ( whitespace.len(), measure(raw("\t"), styles).width ) } else { let whitespace = line.match(regex("^( *).*$")) .at("captures") .at(0) ( calc.floor(whitespace.len() / tab-size), measure(raw("a" * tab-size), styles).width ) } _build-indent-guides( indent-guides, raw-line, line-index, lines.len(), indent-level, indent-size, inset, row-gutter ) }) } raw-line } table-data.push(content) line-index += 1 } } // display content set par(justify: false) align(center, block( stroke: stroke, inset: inset, fill: fill, width: auto, breakable: true )[ #table( columns: if line-numbers {2} else {1}, inset: 0pt, stroke: none, fill: none, row-gutter: row-gutter, column-gutter: column-gutter, align: if line-numbers { (x, _) => (right+horizon, left).at(x) } else { left }, ..table-data ) ]) }
https://github.com/AxiomOfChoices/Typst
https://raw.githubusercontent.com/AxiomOfChoices/Typst/master/Miscellaneous/Affidavit.typ
typst
#table( [<NAME>], [#set align(right); 4455 Earnscliffe Road \ Montreal, QC, H4A3E9 \ +1-514-443-4536 \ #link("https://nataliereznikov.com")[nataliereznikov.com] \ #link("mailto:<EMAIL>")[<EMAIL>] ], columns: (50%, 50%), stroke: none, ) I, <NAME>, hereby confirm that I am the mother of <NAME> and that I am willing to financially support him during his studies in the US at MIT. My support will consist of 5600\$ US dollars over the course of his first year.
https://github.com/piepert/philodidaktik-hro-phf-ifp
https://raw.githubusercontent.com/piepert/philodidaktik-hro-phf-ifp/main/src/parts/spue/leistungsmessung/beispiele.typ
typst
Other
#import "/src/template.typ": * == Beispiel: Schriftlicher Dialog Im Folgenden finden Sie ein Beispiel für eine Leistungsmessung in Form eines schriftlichen Dialogs. #include "/src/lernerfolgskontrollen/spue01/main.typ"
https://github.com/Pablo-Gonzalez-Calderon/showybox-package
https://raw.githubusercontent.com/Pablo-Gonzalez-Calderon/showybox-package/main/README.md
markdown
MIT License
# Showybox (v2.0.3) **Showybox** is a Typst package for creating colorful and customizable boxes. _Please note that this repository contains the latest (development) version of this package and **may not yet be published at Typst's official package repository**. If you want to use this package, see https://github.com/typst/packages/tree/main/packages/preview for the latest stable version_ ## Usage To use this library through the Typst package manager (for Typst 0.6.0 or greater), write `#import "@preview/showybox:2.0.2": showybox` at the beginning of your Typst file. Once imported, you can create an empty showybox by using the function `showybox()` and giving a default body content inside the parenthesis or outside them using squared brackets `[]`. By default a `showybox` with these properties will be created: - No title - No shadow - Not breakable - Black borders - White background - `5pt` of border radius - `1pt` of border thickness ```typst #import "@preview/showybox:2.0.2": showybox #showybox( [Hello world!] ) ``` <h3 align="center"> <img alt="Hello world! example" src="assets/hello-world.png" style="max-width: 95%; background-color: #FFFFFF; padding: 10px; box-shadow: 1pt 1pt 10pt 0pt #AAAAAA; border-radius: 4pt"> </h3> Looks quite simple, but the "magic" starts when adding a title, color and shadows. The following code creates two "unique" boxes with defined colors and custom borders: ```typst // First showybox #showybox( frame: ( border-color: red.darken(50%), title-color: red.lighten(60%), body-color: red.lighten(80%) ), title-style: ( color: black, weight: "regular", align: center ), shadow: ( offset: 3pt, ), title: "Red-ish showybox with separated sections!", lorem(20), lorem(12) ) // Second showybox #showybox( frame: ( dash: "dashed", border-color: red.darken(40%) ), body-style: ( align: center ), sep: ( dash: "dashed" ), shadow: ( offset: (x: 2pt, y: 3pt), color: yellow.lighten(70%) ), [This is an important message!], [Be careful outside. There are dangerous bananas!] ) ``` <h3 align="center"> <img alt="Further examples" src="assets/two-easy-examples.png" style="max-width: 95%; background-color: #FFFFFF; padding: 10px 10px; box-shadow: 1pt 1pt 10pt 0pt #AAAAAA; border-radius: 4pt"> </h3> ## Reference The `showybox()` function can receive the following parameters: - `title`: A string used as the title of the showybox - `footer`: A string used as the footer of the showybox - `frame`: A dictionary containing the frame's properties - `title-style`: A dictionary containing the title's styles - `body-style`: A dictionary containing the body's styles - `footer-style`: A dictionary containing the footer's styles - `sep`: A dictionary containing the separator's properties - `shadow`: A dictionary containing the shadow's properties - `width`: A relative length indicating the showybox's width - `align`: An unidimensional alignement for the showybox in the page - `breakable`: A boolean indicating whether a showybox can break if it reached an end of page - `spacing`: Space above and below the showybox - `above`: Space above the showybox - `below`: Space below the showybox - `body`: The content of the showybox ### Frame properties - `title-color`: Color used as background color where the title goes (default is `black`) - `body-color`: Color used as background color where the body goes (default is `white`) - `footer-color`: Color used as background color where the footer goes (default is `luma(85)`) - `border-color`: Color used for the showybox's border (default is `black`) - `inset`: Inset used for title, body and footer elements (default is `(x: 1em, y: 0.65em)`) if none of the followings are given: - `title-inset`: Inset used for the title - `body-inset`: Inset used for the body - `footer-inset`: Inset used for the body - `radius`: Showybox's radius (default is `5pt`) - `thickness`: Border thickness of the showybox (default is `1pt`) - `dash`: Showybox's border style (default is `solid`) ### Title styles - `color`: Text color (default is `white`) - `weight`: Text weight (default is `bold`) - `align`: Text align (default is `left`) - `sep-thickness`: Thickness of the separator between title and body (default is `1pt`) - `boxed-style`: If it's a dictionary of properties, indicates that the title must appear like a "floating box" above the showybox. If it's ``none``, the title appears normally (default is `none`) #### Boxed styles - `anchor`: Anchor of the boxed title - `y`: Vertical anchor (`top`, `horizon` or `bottom` -- default is `horizon`) - `x`: Horizontal anchor (`left`, `start`, `center`, `right`, `end` -- default is `left`) - `offset`: How much to offset the boxed title in x and y direction as a dictionary with keys `x` and `y` (default is `0pt`) - ``radius``: Boxed title radius as a dictionary or relative length (default is `5pt`) ### Body styles - `color`: Text color (default is `black`) - `align`: Text align (default is `left`) ### Footer styles - `color`: Text color (default is `luma(85)`) - `weight`: Text weight (default is `regular`) - `align`: Text align (default is `left`) - `sep-thickness`: Thickness of the separator between body and footer (default is `1pt`) ### Separator properties - `thickness`: Separator's thickness (default is `1pt`) - `dash`: Separator's style (as a `line` dash style, default is `"solid"`) - `gutter`: Separator's space above and below (defalut is `0.65em`) ### Shadow properties - `color`: Shadow color (default is `black`) - `offset`: How much to offset the shadow in x and y direction either as a length or a dictionary with keys `x` and `y` (default is `4pt`) ## Gallery ### Colors for title, body and footer example (Stokes' theorem) <h3 align="center"> <img alt="Encapsulation" src="assets/stokes-example.png" style="max-width: 95%; background-color: #FFFFFF; padding: 10px 10px; box-shadow: 1pt 1pt 10pt 0pt #AAAAAA; border-radius: 4pt"> </h3> ### Boxed-title example (Clairaut's theorem) <h3 align="center"> <img alt="Encapsulation" src="assets/clairaut-example.png" style="max-width: 95%; background-color: #FFFFFF; padding: 10px 10px; box-shadow: 1pt 1pt 10pt 0pt #AAAAAA; border-radius: 4pt"> </h3> ### Encapsulation example <h3 align="center"> <img alt="Encapsulation" src="assets/encapsulation-example.png" style="max-width: 95%; background-color: #FFFFFF; padding: 10px 10px; box-shadow: 1pt 1pt 10pt 0pt #AAAAAA; border-radius: 4pt"> </h3> ### Breakable showybox example (Newton's second law) <h3 align="center"> <img alt="Enabling breakable" src="assets/newton-example.png" style="max-width: 95%; padding: 10px 10px; background-color: #FFFFFF; box-shadow: 1pt 1pt 10pt 0pt #AAAAAA; border-radius: 4pt"> </h3> ### Custom radius and title's separator thickness example (Carnot's cycle efficency) <h3 align="center"> <img alt="Custom radius" src="assets/carnot-example.png" style="max-width: 95%; background: #FFFFFF; padding: 10px 10px; box-shadow: 1pt 1pt 10pt 0pt #AAAAAA; border-radius: 4pt"> </h3> ### Custom border dash and inset example (Gauss's law) <h3 align="center"> <img alt="Custom radius" src="assets/gauss-example.png" style="max-width: 95%; background: #FFFFFF; padding: 10px 10px; box-shadow: 1pt 1pt 10pt 0pt #AAAAAA; border-radius: 4pt"> </h3> ### Custom footer's separator thickness example (Divergence's theorem) <h3 align="center"> <img alt="Custom radius" src="assets/divergence-example.png" style="max-width: 95%; background: #FFFFFF; padding: 10px 10px; box-shadow: 1pt 1pt 10pt 0pt #AAAAAA; border-radius: 4pt"> </h3> ### Colorful shadow example (Coulomb's law) <h3 align="center"> <img alt="Custom radius" src="assets/coulomb-example.png" style="max-width: 95%; background: #FFFFFF; padding: 10px 10px; box-shadow: 1pt 1pt 10pt 0pt #AAAAAA; border-radius: 4pt"> </h3> ## Changelog ### Version 2.0.3 - Revert fix breakable box empty before new page. Layout didn't converge ### Version 2.0.2 - Remove deprecated functions in Typst 0.12.0 - Fix breakable box empty before new page ### Version 2.0.1 - Fix bad behaviours of boxed-titles ``anchor`` inside a ``figure`` - Fix wrong ``breakable`` behaviour of showyboxes inside a ``figure`` - Fix Manual and README's Stokes theorem example ### Version 2.0.0 _Special thanks to <NAME> (<https://github.com/Andrew15-5>) for the feedback while creating the new behaviours for boxed-titles_ - Update ``type()`` conditionals to Typst 0.8.0 standards - Add ``boxed-style`` property, with ``anchor``, ``offset`` and ``radius`` properties. - Refactor ``showy-inset()`` for being general-purpose. Now it's called ``showy-value-in-direction()`` and has a default value for handling properties defaults - Now sharp corners can be set by giving a dictionary to frame ``radius`` (e.g. ``radius: (top: 5pt, bottom: 0pt)``). Before this only was possible for untitled showyboxes. - Refactor shadow functions to be in a separated file. - Fix bug of bad behaviour while writing too long titles. - Fix bug while rendering separators with custom thickness. Now the thickness is gotten properly. - Fix bad shadow drawing in showyboxes with a boxed-title that has a "extreme" `offset` value. - Fix bad sizing while creating showyboxes with a `width` of less than `100%`, and a shadow. ### Version 1.1.0 - Added `boxed` option in title styles - Added `boxed-align` in title styles - Added `sep-thickness` for title and footer - Refactored repository's files layout ### Version 1.0.0 - Fixed shadow displacement - **Details:** Instead of displacing the showybox's body from the shadow, now the shadow is displaced from the body. _Changes below were performed by <NAME> (<https://github.com/jneug>)_ - Added `title-inset`, `body-inset`, `footer-inset` and `inset` options - **Details:** `title-inset`, `body-inset` and `footer-inset` will set the inset of the title, body and footer area respectively. `inset` is a fallback for those areas. - Added a `sep.gutter` option to set the spacing around separator lines - Added option `width` to set the width of a showybox - Added option `align` to move a showybox with `width` < 100% along the x-axis - **Details:** A showybox is now wrapped in another block to allow alignment. This also makes it possible to pass the spacing options `spacing`, `above` and `below` to `#showybox()`. - Added `footer` and `footer-style` options - **Details:** The optional footer is added at the bottom of the box. ### Version 0.2.1 _All changes listed here were performed by <NAME> (<https://github.com/jneug>)_ - Added the `shadow` option - Enabled auto-break (`breakable`) functionality for titled showyboxes - Removed a thin line that appears in showyboxes with no borders or dashed borders ### Version 0.2.0 - Improved code documentation - Enabled an auto-break functionality for non-titled showyboxes - Created a separator functionality to separate content inside a showybox with a horizontal line ### Version 0.1.1 - Changed package name from colorbox to showybox - Fixed a spacing bug in encapsulated showyboxes - **Details:** When a showybox was encapsulated inside another, the spacing after that showybox was `0pt`, probably due to some "fixes" improved to manage default spacing between `rect` elements. The issue was solved by avoiding `#set` statements and adding a `#v(-1.1em)` to correct extra spacing between the title `rect` and the body `rect`. ### Version 0.1.0 - Initial release
https://github.com/Ngan-Ngoc-Dang-Nguyen/thesis
https://raw.githubusercontent.com/Ngan-Ngoc-Dang-Nguyen/thesis/main/hoi-nghi-Nha-Trang/demo.typ
typst
// #import "../polylux.typ": * #import "@preview/polylux:0.3.1": * #import themes.clean: * #show link: set text(blue) #set text(font: "Inria Sans") // #show heading: set text(font: "Vollkorn") #show raw: set text(font: "JuliaMono") #show: clean-theme.with( footer: [<NAME>, August 2024], //short-title: [Polylux demo], //logo: image("../assets/logo.png"), ) #set text(size: 20pt) #title-slide( title: [Upgrading Stability Radius Model for Enhancing Robustness of Median Location on Tree Networks ], //subtitle: "An overview over all the features", authors:[#underline[<NAME>], <NAME>, <NAME>, <NAME>], date: "August 2024", ) #slide(title:"The main content")[ *1. Stability Radius.* *2. Upgrading Stability Radidus.*] #new-section-slide("1. Stability Radidus" ) #slide[ Let $T = (V, E)$ be a tree network with vertex set $V = {v_1, ..., v_n}$ and edge set $E$. Each vertex $v_i ∈ V$ has a nonnegative weight $w_i$ and $sum_(i=1) ^n w_i =1 $. Every edge length also has to be positive. #import "@preview/cetz:0.1.2": canvas, plot #import "@preview/cetz:0.2.2" #import "@preview/cetz:0.1.2" #only(1)[ #align(center)[#canvas(length: 10%, { import cetz.draw: * let y = 2 let x = 4 let y-space = 1 let h=1.4 circle((0*h,3), radius: 0.05,fill:black, name: "v1") content("v1.bottom", $v_1 (0.1)$, anchor: "left", padding: 0.2) circle((-2*h, 2), radius: 0.05, fill: black, name: "v2") content("v2.bottom", $v_2 (0.13)$, anchor: "left", padding: 0.2) circle((-3*h, 1), radius: 0.05,fill:black, name: "v5") content("v5.bottom", $v_5 (0.1)$, anchor: "left", padding: 0.2) circle((-1*h, 1), radius: 0.05,fill:black, name: "v6") content("v6.bottom", $v_6 (0.1)$, anchor: "left", padding: 0.2) circle((0*h, 2), radius: 0.05, fill: black, name: "v3") content("v3.bottom", $v_3 (0.06)$, anchor: "left", padding: 0.2) circle((0*h, 1), radius: 0.05, fill: black, name: "v7") content("v7.bottom", $v_7 (0.06)$, anchor: "left", padding: 0.2) circle((2*h, 2), radius: 0.05, fill: black, name: "v4") content("v4.bottom", $v_4 (0.15)$, anchor: "left", padding: 0.2) circle((1*h, 1), radius: 0.05, fill: black, name: "v8") content("v8.bottom", $v_8 (0.2)$, anchor: "left", padding: 0.2) circle((3*h, 1), radius: 0.05, fill:black, name: "v9") content("v9.bottom", $v_9 (0.1)$, anchor: "left", padding: 0.2) line("v1", "v2") line("v1", "v3") line("v1", "v4") line("v2", "v5") line("v2", "v6") line("v3", "v7") line("v4", "v8") line("v4", "v9") } )]] #align(center)[*Figure 1.* A weight tree] // This presentation is supposed to briefly showcase what you can do with this // package. // For a full documentation, read the // #link("https://polylux.dev/book/")[online book]. ] #slide(title: "1-median on tree")[ Let $d(x, v_i)$ be the length of the shortest path between $x$ and $v_i$. A vertex $x^*$ is called a 1-median of $T$, if $ f(x^*) ≤ f(x) quad forall x in V $ where $f(x)= sum_(i=1) ^n w_i d(x,v_i)$ *Theorem 1.* _ A point $x^*$ is a median on tree $T$ w.r.t weight vector if and only if_ $ angle.l w, bb(1)_T_u angle.r <= W/2, forall u in N(x^*) $ //Có thể tìm kiếm điểm 1-median bằng thuật toán nuốt lá của Goldman. ] #slide[*Example 1.* #import "@preview/cetz:0.1.2": canvas, plot #import "@preview/cetz:0.2.2" #import "@preview/cetz:0.1.2" #only(1)[ #align(center)[#canvas(length: 10%, { import cetz.draw: * let y = 2 let x = 4 let y-space = 1 let h=1.4 circle((0*h,3), radius: 0.05,fill:black, name: "v1") content("v1.bottom", $v_1 (0.1)$, anchor: "left", padding: 0.2) circle((-2*h, 2), radius: 0.05, fill: black, name: "v2") content("v2.bottom", $v_2 (0.13)$, anchor: "left", padding: 0.2) circle((-3*h, 1), radius: 0.05,fill:black, name: "v5") content("v5.bottom", $v_5 (0.1)$, anchor: "left", padding: 0.2) circle((-1*h, 1), radius: 0.05,fill:black, name: "v6") content("v6.bottom", $v_6 (0.1)$, anchor: "left", padding: 0.2) circle((0*h, 2), radius: 0.05, fill: black, name: "v3") content("v3.bottom", $v_3 (0.06)$, anchor: "left", padding: 0.2) circle((0*h, 1), radius: 0.05, fill: black, name: "v7") content("v7.bottom", $v_7 (0.06)$, anchor: "left", padding: 0.2) circle((2*h, 2), radius: 0.05, fill: black, name: "v4") content("v4.bottom", $v_4 (0.15)$, anchor: "left", padding: 0.2) circle((1*h, 1), radius: 0.05, fill: black, name: "v8") content("v8.bottom", $v_8 (0.2)$, anchor: "left", padding: 0.2) circle((3*h, 1), radius: 0.05, fill:black, name: "v9") content("v9.bottom", $v_9 (0.1)$, anchor: "left", padding: 0.2) line("v1", "v2") line("v1", "v3") line("v1", "v4") line("v2", "v5") line("v2", "v6") line("v3", "v7") line("v4", "v8") line("v4", "v9") } )]] #align(center)[*Figure 1.* A weight tree] In this case, $v_1$ is 1-median point. ] // We used the `title` argument of the `#slide` function for that: // ```typ // #slide(title: "First slide")[ // ... // ] // ``` // (This works because we utilise the `clean` theme; more on that later.) #slide(title: "Stability Radius")[ Definition of the stability radius of $v_1$ w.r.t weight vector $w$: $ R(w) = sup{epsilon >= 0: v_1 in X^*_tilde(w), quad forall tilde(w) in [w-epsilon, w+ epsilon] sect RR_+^n} $ *Theorem 2.* _We have_ $ R(w) >= underline(R)(w) = min_(u in N(v_1)) 1/n (1- 2 angle.l w, bb(1)_T_u angle.r) (1). $ _Furthermore, the equality in (1) holds if $underline(R)(w) < min_(i=1,...,n) w_i$_ ] #slide[ *Example 2.* #import "@preview/cetz:0.1.2": canvas, plot #import "@preview/cetz:0.2.2" #import "@preview/cetz:0.1.2" #only(1)[ #align(center)[#canvas(length: 10%, { import cetz.draw: * let y = 2 let x = 4 let y-space = 1 let h=1.4 circle((0*h,3), radius: 0.05,fill:black, name: "v1") content("v1.bottom", $v_1 (0.1)$, anchor: "left", padding: 0.2) circle((-2*h, 2), radius: 0.05, fill: black, name: "v2") content("v2.bottom", $v_2 (0.13)$, anchor: "left", padding: 0.2) circle((-3*h, 1), radius: 0.05,fill:black, name: "v5") content("v5.bottom", $v_5 (0.1)$, anchor: "left", padding: 0.2) circle((-1*h, 1), radius: 0.05,fill:black, name: "v6") content("v6.bottom", $v_6 (0.1)$, anchor: "left", padding: 0.2) circle((0*h, 2), radius: 0.05, fill: black, name: "v3") content("v3.bottom", $v_3 (0.06)$, anchor: "left", padding: 0.2) circle((0*h, 1), radius: 0.05, fill: black, name: "v7") content("v7.bottom", $v_7 (0.06)$, anchor: "left", padding: 0.2) circle((2*h, 2), radius: 0.05, fill: black, name: "v4") content("v4.bottom", $v_4 (0.15)$, anchor: "left", padding: 0.2) circle((1*h, 1), radius: 0.05, fill: black, name: "v8") content("v8.bottom", $v_8 (0.2)$, anchor: "left", padding: 0.2) circle((3*h, 1), radius: 0.05, fill:black, name: "v9") content("v9.bottom", $v_9 (0.1)$, anchor: "left", padding: 0.2) line("v1", "v2") line("v1", "v3") line("v1", "v4") line("v2", "v5") line("v2", "v6") line("v3", "v7") line("v4", "v8") line("v4", "v9") } )]] #align(center)[*Figure 1.* A weight tree] $underline(R)(w) = min{epsilon_v_2 , epsilon_v_3 , epsilon_v_4 } = 0.1/9$ since $epsilon_v_2 = 0.34/9, epsilon_v_3 = 0.76/9, epsilon_v_4 = 0.1/9$ ] #new-section-slide("Upgrading Stability Radius of median point") #slide(title: "Formulations")[ Let #text(blue)[$T = (V, E)$] be a tree network with vertex set #text(blue)[$V = {v_1, ..., v_n}$] and edge set #text(blue)[$E$]. Each vertex #text(blue)[$v_i in V$] has a nonnegative weight #text(blue)[$w_i$] Every edge length also has to be positive. // #pause Let #text(blue)[$v_1 in V$] be #text(blue)[1-median point] associated with weight vector $w in RR^n_+$. The total mass of $w$ is unchanged and normalized by the unit mass constraint #text(blue)[$ sum_(i=1)^n w_i =1 $] #pause Given #text(blue)[a budget $B ≥ 0$], the goal is to modify the weights from $w$ to some $tilde(w) in RR^n_+$ within the budget $B$. ] #slide[The problem model is stated as follows: $ max quad & underline(R)(tilde(w)) quad quad quad quad quad quad quad #text(blue)[(USR-1)]\ "s.t." quad & norm(tilde(w)-w)_1 <= B\ & v_1 "is 1-median w.r.t" tilde(w)\ & sum^n_(i=1) tilde(w)_i = 1\ & norm(tilde(w)-w)_infinity <= epsilon_0 $ ] #let example(body) = block( width: 100%, inset: .5em, fill: aqua.lighten(80%), radius: .5em, text(size: .8em, body) ) #let Rdown = $underline(R)$ #slide[ $ max_(tilde(w)) Rdown(tilde(w)) = max_tilde(w) min_(u in N(v_1))1/n -2/n min_tilde(w) max_(u in N(v_1)) angle.l w, bb(1)_T_u angle.r $ Let $x_i:= tilde(w)_i - w_i quad forall i= 1,...,n$ The problem $#text(blue)[(USR-1)]$ can be rewritten as follows: $ min quad & max_(u in N(v_1)) angle.l w + x, bb(1)_T_u angle.r quad quad #text(blue)[(USR-2)]\ "s.t." quad & norm(x)_1 <= B\ & sum^n_(i=1) x_i = 0\ & x_i in [-epsilon_0; epsilon_0], forall i = 1,...,n $ ] #slide(title: "Parametric version")[ #text(blue)[*"Given some target objective value $t$, what is the minimum budget we should prepare to reach objective value bounded by $t$?”*] Considering the following problem: $ min quad & norm(x)_1 quad quad quad quad quad quad #text(blue)[(PUSR-3)]\ "s.t." quad & max_(u in N(v_1)) angle.l w + x, bb(1)_T_u angle.r <= t\ & sum^n_(i=1) x_i = 0\ & x_i in [-epsilon_0; epsilon_0], forall i = 1,...,n $ ] #slide[ Let #text(blue)[$x^*$] an #text(blue)[optimal solution] and #text(blue)[$t^*$] the #text(blue)[optimal objective value] of (USR-2). Let #text(blue)[$hat(x)(t)$] be #text(blue)[an optimal solution] and #text(blue)[$beta(t)$] be #text(blue)[the optimal objective value] of (PUSR-3) corresponding to parameter #text(blue)[$t$]. *Lemma 1.* $ beta(t) <= B <=> t ≥ t^* $ #pause *Theorem 3.* _The optimal objective value $t^*$ of (USR-2) satisfies_ $ t^* = inf{t : beta(t) ≤ B } $ and $hat(x)(t^*)$ is an optimal solution of (USR-2). ] #let zup = $overline(z)$ #slide[ *Theorem 4.* _There exists an optimal solution $hat(x)(t)$ of (DUSR-3) that assigns the same value to $hat(x)(t)$ for all vertices $v_i$ within each subtree $T_u$, where $u in N (v_1)$._ #text(blue)[Reducing the dimension] of problem (DUSR-3) from #text(blue)[$n$] to #text(blue)[$k+1$] where $k$ is the degree of median point $v_1$ #pause Let #text(blue)[$N(v_1) = {u_1, ...., u_k}, u_0 = v_1$] and #text(blue)[$ T_u_0 = {v_1}$] Let #text(blue)[$z_0 = x_1$] the modification associated with the median point $v_1$, #text(blue)[$z_j = angle.l x, bb(1)_T_u_j angle.r$, $zup_j = epsilon_0|T_u_j|$, $gamma_j = angle.l w, bb(1)_T_u_j angle.r$] the total weight of subtree $T_u_j$ for $j = 1, ...,k$. ] #slide[ $ min quad & sum_(j=0)^k abs(z_j) quad quad quad quad #text(blue)[(PUSR-4)]\ "s.t." quad & max_(j=1,...,k) (gamma_j + z_j) <= t\ & sum^k_(j=1) z_j = 0\ & z_j in [-zup_j; zup_j], forall j = 0,1,...,k $ The problem #text(blue)[$("PUSR-4")$] can be solved in $O(k log k)$. The problem #text(blue)[$("PUSR-3")$] can be solved in $O(n+k log k)$ ] #new-section-slide("Solving upgrading stability radius problem") #slide[ We have the following diagram: #align(center)[ #import "@preview/cetz:0.1.2" #import "@preview/cetz:0.1.2": canvas, plot // #import "@preview/cetz:0.2.2" // #import "@preview/cetz:0.1.2 #canvas(length: 10%, { import cetz.draw: * let (y1, y2, y3, y4) = (3,2,1, 4) let (x1, x2, x3, x4) = (1, 3, 5, 7) let x0 = 0 let r = 0.5 let h =-2 rect((0,0), (2.2, 0.5), name: "p1") rect((6,0), (6.5+2, 0.5), name: "p2") rect((0,h), (2.5, h+0.5), name: "p4") rect((6,h), (6.5+2, h+0.5), name: "p3") line("p1.right", "p2.left", mark: (end: ">"), name: "l1") line("p2.bottom", "p3.top", mark: (end: ">"), name: "l2") line("p3.left", "p4.right", mark: (end: ">"), name: "l3") content("p1.center", [#text(blue)[$("USR"-1) quad "&" quad w^*$]], anchor: none, padding: 0.3) content("p2.center", [#text(blue)[$("USR"-2) quad "&" quad x^*$]], anchor: none, padding: 0.3) content("p3.center", [#text(blue)[$("PUSR"-3) quad "&" quad hat(x)(t)$]], anchor: none, padding: 0.3) content("p4.center", [#text(blue)[$("PUSR"-4) quad "&" quad hat(z)(t)$]], anchor: none, padding: 0.2) content("l1.bottom", [*Remove median constraint*], anchor: "bottom", padding: 0.2) content("l1.top", [*$x^* = w^* - w$*], anchor: "top", padding: 0.2) content("l2.left", [*Swap objective and* *budget constraint*], anchor: "left", padding: 0.2) content("l2.right", [*Theorem 3*], anchor: "right", padding: 0.2) content("l3.bottom", [*Theorem 4*], anchor: "bottom", padding: 0.2) content("l3.top", [*Reduce dimension*], anchor: "top", padding: 0.2) })] ] #new-section-slide("Thank you for your attention!") // #slide(title: "References")[ // [1] <NAME>., <NAME>.: Fifty years of location theory - a selective review. // _European Journal of Operational Research_ *318*(3), 701–718 (2024) // [2] <NAME>., <NAME>., <NAME>.: Introduction to Location Science, // pp. 1–21. Springer, Cham (2019) // [3] <NAME>., <NAME>.: The p-median problem with upgrading of transportation // costs and minimum travel time allocation. Computers & Operations Research // 159, 106354 (2023) // [4] <NAME>., <NAME>., <NAME>.: Tolerances applied in combinatorial // optimization. J. Comput. Sci 2(9), 716–734 (2006) // [5] <NAME>., <NAME>.: On parametric medians of trees. Transportation science // 26(2), 149–156 (1992) // [6] <NAME>.: Bounds on the weber problem solution under conditions of uncer- // tainty. Journal of Regional Science 18(1) (1978) // [7] <NAME>.: Sensitivity analysis of the optimal location of a facility. Naval // Research Logistics Quarterly 32(2), 209–224 (1985) // [8] <NAME>., <NAME>.: Calculation of stability radii for combinatorial // optimization problems. Operations Research Letters 23(1-2), 1–7 (1998) // [9] <NAME>., <NAME>., <NAME>.: The inverse 1-median problem on // a cycle. Discrete Optimization 5(2), 242–253 (2008) // 15 // ] /*
https://github.com/pedrofp4444/BD
https://raw.githubusercontent.com/pedrofp4444/BD/main/report/content/[5] Implementação Física/explicação.typ
typst
#let explicação = { [ == Apresentação e explicação da base de dados implementada De forma a iniciar o desenvolvimento do sistema de gestão de base de dados, decidimos criar a implementação mySQL de cada tabela apresentada anteriormente no modelo lógico. Dá-se início ao processo com duas instruções SQL essenciais: a primeira é responsável pela criação da base de dados com o nome atribuído _Lusium_, a segunda indica ao sistema qual a base de dados que deve ser utilizada para as operações executadas. #align(center)[ #figure( kind: image, caption: [Instruções SQL para criar e utilizar a base de dados.], block( fill: rgb("#f2f2eb"), inset: 8pt, ```sql CREATE DATABASE IF NOT EXISTS Lusium; USE Lusium; ``` ) ) ] \ A primeira tabela a ser implementada no modelo físico é a Função, esta que, ao seguir a estrutura habitual de SQL, é inaugurada com duas colunas. Possui o identificador único "Função_ID", que é definido pelos parâmetros "INT", que define o tipo de dados, "PRIMARY KEY" que garante a atomicidade e capacidade identificativa, "AUTO_INCREMENT" para que o sistema atribua automaticamente um identificador sequencial e "NOT NULL", para assegurar que o valor existe. Representa-se também a "Designação", do tipo "ENUM()", para restringir os valores possíveis na coluna Operacional, Detetive ou Representante, apoiada pelo "NOT NULL", de forma a certificar uma atribuição de valor. #grid( align: horizon, columns: 2, column-gutter: 0pt, figure( caption: [Tabela lógica da Função.], image("../../images/FunçãoTabela.png", width:50%) ), figure( kind: image, caption: [Implementação correspondente à Função.], block( fill: rgb("#f2f2eb"), inset: 8pt, ```sql -- Criação da tabela Função CREATE TABLE Função ( Função_ID INT AUTO_INCREMENT NOT NULL, Designação ENUM( 'Operacional', 'Detetive', 'Representante') NOT NULL, PRIMARY KEY (Função_ID) ); ``` ) ) ) \ A tabela Funcionário armazena dados essenciais dos colaboradores. A coluna “Funcionário_ID” é um “INT” que serve como “PRIMARY KEY” e é “NOT NULL”, garantindo que cada funcionário tenha um identificador único. “Nome” é um “VARCHAR(75)” e também “NOT NULL”, permitindo nomes com até 75 caracteres. “Data_de_nascimento” é um campo “DATE” e “NOT NULL”, registrando a data de nascimento de cada funcionário. “Salário” é um “INT” e “NOT NULL”, refletindo o salário do funcionário. “NIF” é um “VARCHAR(10)” e “NOT NULL”, contendo o número fiscal do funcionário. “Fotografia” é um “VARCHAR(150)” e pode ser “NULL”, indicando que a fotografia é opcional. “Função_ID” é um “INT” e “NOT NULL”, atuando como uma chave estrangeira que referencia a tabela Função. #grid( align: horizon, columns: 2, column-gutter: 0pt, figure( caption: [Tabela lógica do Funcionário.], image("../../images/FuncionárioTabela.png", width:50%) ), figure( kind: image, caption: [Implementação correspondente ao Funcionário.], block( fill: rgb("#f2f2eb"), inset: 8pt, ```sql -- Criação da tabela Funcionário CREATE TABLE Funcionário ( Funcionário_ID INT AUTO_INCREMENT NOT NULL, Nome VARCHAR(75) NOT NULL, Data_de_nascimento DATE NOT NULL, Salário INT NOT NULL, NIF VARCHAR(10) NOT NULL, Fotografia VARCHAR(150) NULL, Função_ID INT NOT NULL, PRIMARY KEY (Funcionário_ID), FOREIGN KEY (Função_ID) REFERENCES Função(Função_ID) ); ``` ) ) ) \ A tabela Número de telemóvel é dedicada aos contactos telefónicos dos funcionários. “Número_de_telemóvel_ID” é um “INT”, definido como “PRIMARY KEY” e “NOT NULL”, assegurando a unicidade de cada número. “Funcionário_ID” é um “INT” e “NOT NULL”, estabelecendo uma chave estrangeira que liga o número de telemóvel ao seu respectivo funcionário na tabela Funcionário. #grid( align: horizon, columns: 2, column-gutter: 0pt, figure( caption: [Tabela lógica do Número de Telemóvel.], image("../../images/NumTelemóvelTabela.png", width:50%) ), figure( kind: image, caption: [Implementação correspondente ao Número de Telemóvel.], block( fill: rgb("#f2f2eb"), inset: 8pt, ```sql -- Criação da tabela Número de telemóvel CREATE TABLE Número_de_telemóvel ( Número_de_telemóvel_ID INT NOT NULL, Funcionário_ID INT NOT NULL, PRIMARY KEY (Número_de_telemóvel_ID), FOREIGN KEY (Funcionário_ID) REFERENCES Funcionário(Funcionário_ID) ); ``` ) ) ) \ A tabela Gere representa a hierarquia de gestão. “Funcionário_Gestor_ID” e “Funcionário_ID” são ambos “INT” e “NOT NULL”, formando uma “PRIMARY KEY” composta que identifica cada relação de gestão. Ambos são também chaves estrangeiras que apontam para “Funcionário_ID” na tabela Funcionário, delineando quem gere quem. #grid( align: horizon, columns: 2, column-gutter: 0pt, figure( caption: [Tabela lógica do Gere.], image("../../images/GereTabela.png", width:50%) ), figure( kind: image, caption: [Implementação correspondente ao Gere.], block( fill: rgb("#f2f2eb"), inset: 8pt, ```sql -- Criação da tabela Gere CREATE TABLE Gere ( Funcionário_Gestor_ID INT NOT NULL, Funcionário_ID INT NOT NULL, PRIMARY KEY (Funcionário_Gestor_ID, Funcionário_ID), FOREIGN KEY (Funcionário_Gestor_ID) REFERENCES Funcionário(Funcionário_ID), FOREIGN KEY (Funcionário_ID) REFERENCES Funcionário(Funcionário_ID) ); ``` ) ) ) \ A tabela Terreno regista os terrenos de mineração. “Terreno_ID” é um “INT”, marcado como “PRIMARY KEY”, "AUTO_INCREMENT" para que o sistema atribua automaticamente um identificador sequencial e “NOT NULL”, identificando cada terreno de forma única. “Minério_previsto” e “Minério_coletado” são ambos “INT” e “NOT NULL”, quantificando o minério esperado e extraído, respectivamente. #grid( align: horizon, columns: 2, column-gutter: 0pt, figure( caption: [Tabela lógica do Terreno.], image("../../images/TerrenoTabela.png", width:50%) ), figure( kind: image, caption: [Implementação correspondente ao Terreno.], block( fill: rgb("#f2f2eb"), inset: 8pt, ```sql -- Criação da tabela Terreno CREATE TABLE Terreno ( Terreno_ID INT AUTO_INCREMENT NOT NULL, Minério_previsto INT NOT NULL, Minério_coletado INT NOT NULL, PRIMARY KEY (Terreno_ID) ); ``` ) ) ) \ A tabela Trabalha associa funcionários aos terrenos onde operam. “Funcionário_ID” e “Terreno_ID” são “INT” e “NOT NULL”, constituindo uma “PRIMARY KEY” composta que garante a singularidade da relação. Estas colunas são chaves estrangeiras que referenciam as tabelas “Funcionário” e “Terreno”, respectivamente. #grid( align: horizon, columns: 2, column-gutter: 0pt, figure( caption: [Tabela lógica do Trabalha.], image("../../images/TrabalhaTabela.png", width:50%) ), figure( kind: image, caption: [Implementação correspondente ao Trabalha.], block( fill: rgb("#f2f2eb"), inset: 8pt, ```sql -- Criação da tabela Trabalha CREATE TABLE Trabalha ( Funcionário_ID INT NOT NULL, Terreno_ID INT NOT NULL, PRIMARY KEY (Funcionário_ID, Terreno_ID), FOREIGN KEY (Funcionário_ID) REFERENCES Funcionário(Funcionário_ID), FOREIGN KEY (Terreno_ID) REFERENCES Terreno(Terreno_ID) ); ``` ) ) ) \ A tabela Caso é usada para o acompanhamento de investigações. “Caso_ID” é um “INT”, servindo como “PRIMARY KEY”, "AUTO_INCREMENT" para que o sistema atribua automaticamente um identificador sequencial e “NOT NULL”. “Data_de_abertura” é um campo “DATE” e “NOT NULL”, marcando o início do caso. “Estado” é um “ENUM(‘Aberto’, ‘Fechado’)” e “NOT NULL”, indicando o estado atual do caso. “Estimativa_de_roubo” é um “INT” e “NOT NULL”, estimando o valor subtraído. “Data_de_encerramento” pode ser um campo “DATE” e “NULL”, representando a data de conclusão do caso. “Terreno_ID” é um “INT” e “NOT NULL”, funcionando como uma chave estrangeira que liga o caso ao terreno relevante. #grid( align: horizon, columns: 2, column-gutter: 0pt, figure( caption: [Tabela lógica do Caso.], image("../../images/CasoTabela.png", width:50%) ), figure( kind: image, caption: [Implementação correspondente ao Caso.], block( fill: rgb("#f2f2eb"), inset: 8pt, ```sql -- Criação da tabela Caso CREATE TABLE Caso ( Caso_ID INT AUTO_INCREMENT NOT NULL, Data_de_abertura DATE NOT NULL, Estado ENUM('Aberto', 'Fechado') NOT NULL, Estimativa_de_roubo INT NOT NULL, Data_de_encerramento DATE NULL, Terreno_ID INT NOT NULL, PRIMARY KEY (Caso_ID), FOREIGN KEY (Terreno_ID) REFERENCES Terreno(Terreno_ID) ); ``` ) ) ) \ A tabela Suspeito mantém o registo dos suspeitos nos casos. “Funcionário_ID” e “Caso_ID” são “INT” e “NOT NULL”, formando uma “PRIMARY KEY” composta. “Estado” é um “ENUM(‘Inocente’, ‘Em investigação’, ‘Culpado’)” e “NOT NULL”, refletindo a condição do suspeito. “Envolvimento” é um “INT” e “NOT NULL”, medindo o grau de envolvimento do suspeito no caso. “Notas” é um campo “TEXT” e pode ser “NULL”, permitindo anotações adicionais sobre o suspeito. #grid( align: horizon, columns: 2, column-gutter: 0pt, figure( caption: [Tabela lógica do Suspeito.], image("../../images/SuspeitoTabela.png", width:50%) ), figure( kind: image, caption: [Implementação correspondente ao Suspeito.], block( fill: rgb("#f2f2eb"), inset: 8pt, ```sql -- Criação da tabela Suspeito CREATE TABLE Suspeito ( Funcionário_ID INT NOT NULL, Caso_ID INT NOT NULL, Estado ENUM('Inocente', 'Em investigação', 'Culpado') NOT NULL, Envolvimento INT NOT NULL, Notas TEXT NULL, PRIMARY KEY (Funcionário_ID, Caso_ID), FOREIGN KEY (Funcionário_ID) REFERENCES Funcionário(Funcionário_ID), FOREIGN KEY (Caso_ID) REFERENCES Caso(Caso_ID) ); ``` ) ) ) ] }
https://github.com/freundTech/typst-typearea
https://raw.githubusercontent.com/freundTech/typst-typearea/main/tests/footer-include.query.typ
typst
MIT License
#import "../typearea.typ": * #show: typearea.with( width: 100pt, height: 100pt, div: 10, header-include: true, header-height: 10pt, header-sep: 5pt, ) #context [ #layout(size => [ #metadata(here().position() + size)<result> ]) ] #metadata(( page: 1, x: 10pt, y: 25pt, width: 70pt, height: 55pt, ))<expected>
https://github.com/yhtq/Notes
https://raw.githubusercontent.com/yhtq/Notes/main/复变函数/作业/hw7.typ
typst
#import "../../template.typ": proof, note, corollary, lemma, theorem, definition, example, remark, proposition,der, partialDer, Spec, seqLimit, seqLimitn #import "../../template.typ": * // Take a look at the file `template.typ` in the file panel // to customize this template and discover how it works. #show: note.with( title: "作业7", author: "YHTQ", date: none, logo: none, withOutlined : false, withTitle :false, ) #set heading(numbering: none) (应交时间为4月19日) = p87 == 5 设: $ F(z) = integral_(gamma)^() 1/(w-z) dif w $ 显然 $F(z) = n(gamma, z)$,由缠绕数的概念易知 $F'(z) = 0$\ 另一方面,有: $ 0 = F^((n))(z) = integral_(gamma)^() n!/(w-z)^(n+1) dif w $ 故结论成立 == 8 注意到: $ 0 = integral_(gamma)^() f_i (z) dif z $ 其中 $gamma$ 是任意绕 $a$ 的简单闭曲线,在上式中令 $i -> +infinity$ 并利用一致收敛性保证积分与极限交换顺序可得: $ 0 = integral_(gamma)^() f(z) dif z $ 这对所有区域内的简单闭曲线都成立,且 $f$ 的连续性是熟知的,由 Morera 定理可知 $f$ 是解析的 == 9 由 Morera 只需证明对于任意包裹 $[-1, 1]$ 的简单闭曲线都有: $ integral_(gamma)^() f(z) dif z = 0 $ 即可\ 事实上,任取这样一条曲线,都可以连续地变换到其他包含 $[-1, 1]$ 的曲线,且这样的变换根据柯西积分定理不改变积分值,因此可以让 $gamma$ 充分靠近 $[-1,1]$\ 任取 $epsilon > 0$,由于 $f$ 的连续性应当在紧集: $ D := [-2, 2] times [-1, 1] $ 上一致连续并有上界 $M$,进而存在 $delta > 0$ 使得 $forall x, y in D, norm(x - y) <= 2delta => norm(f(x) - f(y)) < epsilon$\ 由 Morera 只需证明对于区域 $D$ 内任意三角形 $Delta$ 均有: $ integral_(Delta)^() f(z) dif z = 0 $ 即可 - 若 $Delta$ 在 $[-1, 1]$ 的外部且与之不交,则结论显然 - 否则,三角形可以连续收缩到一个与 $[-1, 1]$ 相交或包含它的梯形 $S$,使得 $S$ 的上底和下底与 $RR$ 平行且: $ S subset [-1 - delta, 1 + delta] times [-delta', delta'] $ 其中 $0 < delta' < delta$ 是任取的\ 更进一步,将梯形分为内部最大的正方形和两个三角形,分别计算在这些图形边界上的积分即可 - 先考虑三角形,显然这个三角形是某个内角为原三角形某个内角 $theta$ 的直角三角形,且 $y$ 方向的直角边长度小于 $2 delta'$,进而周长小于 $k delta'$,其中 $k$ 与 $delta, delta'$ 都无关,是只与 $theta$ 有关的常数,因此两个三角形上的积分有估计式: $ norm(integral_(Delta'_1 + Delta'_2) f(z) dif z) <= k' M delta' $ - 再考虑矩形,设其上底为 $[a, b] times {c_1}$,下底为 $[a, b] times {c_2}$,矩形上的积分就是: $ integral_(a)^(b) f(t + c_1 i) dif t + integral_(c_1)^(c_2) f(b + s i) dif s + integral_(b)^(a) f(t + c_2 i) dif t + integral_(c_2)^(c_1) f(a + s i) dif s $ 其中: $ norm(integral_(c_1)^(c_2) f(b + s i) dif s + integral_(c_2)^(c_1) f(a + s i) dif s) &<= 2 abs(c_2 - c_1) M <= 2 delta' M\ norm(integral_(a)^(b) f(t + c_1 i) dif t + integral_(b)^(a) f(t + c_2 i) dif t) &= norm(integral_(a)^(b) f(t + c_1 i) - f(t + c_2 i) dif t)\ &<= integral_(a)^(b) norm(f(t + c_1 i) - f(t + c_2 i)) dif t\ &<= integral_(a)^(b) epsilon dif t\ &= epsilon (b - a)\ &<= 4 epsilon $ 注意到上面所有式子中可以让 $delta', epsilon$ 任意小而不影响其它常数,因此原三角形上的积分就是零,得证 = p99 == 1 设 $C subset G$ 是包含 $gamma$ 的闭区域,可设 $f, f'$ 在其上有上界 $M$\ 任给一个 $[0 ,1]$ 的分划 $0 = x_0 < x_1 < ... < x_n = 1$,则: $ &sum_(i=0)^(n-1) norm(f(gamma(x_(i+1))) - f(gamma(x_i))) \ &= sum_(i=0)^(n-1) norm(integral_(x_i)^(x_(i+1)) f(gamma(t)) dif t)\ &<= sum_(i=0)^(n-1) integral_(x_i)^(x_(i+1)) norm(f(gamma(t))) dif t\ &<= sum_(i=0)^(n-1) M integral_(x_i)^(x_(i+1)) 1 dif t\ &= M v(gamma) $ 表明 $f compose gamma$ 的有界变差有上界,当然意味着可求长 == 4 假设 $f'(a) = 0$,不妨通过平移令 $f(a) = 0$,此时 $a$ 是 $f$ 的二重零点,由本节引理知存在某个 $xi$ 使得 $a$ 周围将存在 $2$ 个不同点使得 $f(z) = xi$,这与 $f$ 是单射矛盾!
https://github.com/diquah/OpenBoard
https://raw.githubusercontent.com/diquah/OpenBoard/main/openboard.typ
typst
MIT License
#let debug_stroke = 0pt #let template(paper: "us-letter", doc) = { set page( paper: paper, footer: context { if counter(page).get().first() > 1 [ #h(1fr) #set text(font: "Roboto Slab", weight: "semibold", size: 10pt, fill: luma(65%)) #counter(page).display( "1 of 1", both: true, ) ] }, margin: (x: 1.2in, y: 0.75in) ) set text(font: "STIX Two Text", size: 11.5pt, weight: 400) show math.equation: set text(font: "STIX Two Math") show strong: set strong(delta: 200) doc } #let title(title: "", subtitle: "", organization: "", class: "", collect_info: (), exam_version: "") = { show par: set block(spacing: 0em) set text(font: "Roboto Slab", fill: luma(35%)) [ #place(top+right, [ #if collect_info.len() > 0 { table( columns: (auto, auto), fill: (luma(50%), white), inset: (x: 0.6em, y: 0.5em), stroke: 1.1pt + luma(50%), ..for info in collect_info { ( text(size: 10pt, weight: "bold", fill: luma(95%))[#info], h(10em) ) } ) } #if exam_version.len() > 0 { block(stroke: 1.5pt + luma(66%), inset: 0.5em)[#text(size: 16pt, weight: "bold", fill: luma(66%))[#exam_version]] } ] ) *#organization* #v(0.75em) #class #v(7em) #line(stroke: 5pt + luma(75%), length: 66%) #text(size: 22pt, weight: "bold")[#title] #v(0.85em) #text(size: 15pt, weight: "semibold")[#subtitle] #v(7em) ] } #let instruct(doc) = { set text(font: "Roboto Slab", weight: "regular", size: 11pt, fill: luma(40%)) show heading: set block(spacing: 2em) show par: set block(spacing: 2em) show list: set list(marker: "—") doc } #let prompt_counter = counter("prompt_counter") #let prompt(allow_overrun: false, doc) = { prompt_counter.step() block(breakable: allow_overrun, table( columns: (auto, auto), stroke: debug_stroke, [ #set text(weight: "black") #prompt_counter.display("1.") ], [ #doc ] ) ) } #let custom_prompt(label, doc) = { show par: set block(spacing: 2em) block(breakable: false, below: 3em, table( columns: (auto, auto), stroke: debug_stroke, [ #set text(weight: "black") #label ], [ #doc ] ) ) } #let section_header(head, info: [], reset_question_count: true) = { if reset_question_count { prompt_counter.update(0) } line(start: (-2mm, 0%), length: 100% + 2mm, stroke: 2.5pt + luma(50%)) block(above: 0in, inset: (x: -2mm, y:0in), table( columns: (auto, auto), stroke: 0pt, inset: 0pt, [ #block(fill: luma(50%), inset: 3mm, above: 0in, text(font: "Roboto Slab", size: 12pt, weight: "black", fill: luma(90%))[#head] ) ], [ #pad(left: 1em, top: 10pt)[ #set text(font: "Roboto Slab", weight: "regular", size: 11pt, fill: luma(45%)) #info ] ] ) ) v(1em) } #let mcq(..options) = { block(breakable: false)[ #table( columns: (auto, auto), inset: (x: 0.5em, y: 0.666em), stroke: debug_stroke, ..for (index, options) in options.pos().enumerate() { (numbering("(A)", index + 1), options) } ) ] } #let frq(..options) = { table( columns: (auto, auto), inset: (x: 0.5em, y: 0.666em), stroke: debug_stroke, ..for (index, options) in options.pos().enumerate() { (numbering("a)", index + 1), options) } ) } #let space(h) = { v(3em * h) } #let graph(w, h, s: 6mm) = { v(1.5em) rect(width: w*s, height: h*s, stroke: 0.5pt + luma(75%), fill: pattern(size: (s, s))[ #rect(stroke: 0.5pt + luma(75%), width: s, height: s) ]) } #let ruled(lines, s: 8mm) = { v(1.5em) for l in range(lines) { block(spacing: 0mm, line(length: 100%, stroke: 0.75pt + gray)) v(s) } }
https://github.com/fenjalien/metro
https://raw.githubusercontent.com/fenjalien/metro/main/tests/num/minimum-decimal-digits/test.typ
typst
Apache License 2.0
#import "/src/lib.typ": num, metro-setup #set page(width: auto, height: auto) #num[12.34] #num(minimum-decimal-digits: 2)[12.34] #num(minimum-decimal-digits: 4)[12.34]
https://github.com/SWATEngineering/Docs
https://raw.githubusercontent.com/SWATEngineering/Docs/main/src/3_PB/PianoDiProgetto/sections/Consuntivo.typ
typst
MIT License
#import "../functions.typ": glossary, team == Consuntivo generale Se si considera che secondo il preventivo aggiornato in occasione dell'#glossary[RTB] si dovevano avere 57 ore produttive rimanenti per lo svolgimento del periodo antecedente alla terza revisione #glossary[CA], è evidente che il team, una volta deciso di non volerla effettuare, ha accelerato il ritmo di lavoro per sfruttare anche le ore in più a disposizione in un lasso di tempo più breve, senza però riuscirci del tutto; tuttavia, bisogna sottolineare anche che, per quanto il team abbia tentato di riportare con accuratezza le ore produttive impiegate all'interno dello #glossary[spreadsheet] "Time & Resource Manager", è probabile che queste siano state sottostimate nella prima parte del progetto (prima della #glossary[PB]), dato che il rapporto ore orologio su ore produttive non era facilmente individuabile per ciascun componente e ha subito variazioni significative con l'avvento della sessione di esami (il che non si è verificato dopo l'#glossary[RTB]). Per questi motivi il team si ritiene comunque soddisfatto del proprio rendimento e, soprattutto, di essere riuscito a rispettare le scandenze temporali previste dopo l'#glossary[RTB]. In occasione del termine della pianificazione, si riportano le ore cumulativamente utilizzate per ciascun ruolo rispetto a quelle preventivate per lo svolgimento di #glossary[RTB] e #glossary[PB]: - Responsabile: 62.5 ore (contro le 63 preventivate); - Amministratore: 86 ore (contro le 87 preventivate); - Analista: 50.5 ore (contro le 54 preventivate); - Progettista: 59 ore (contro le 60 preventivate); - Programmatore: 137 ore (contro le 139 preventivate); - Verificatore: 160 ore (contro le 167 preventivate). Si riportano anche le ore utilizzate per ruolo da parte di ogni componente del team #team rispetto a quelle preventivate per lo svolgimento di #glossary[RTB] e #glossary[PB]: #figure( table( columns:(auto,auto,auto,auto,auto,auto,auto,auto), align: (x, y) => (center,center,center,center,center,center,center,center).at(x), fill:(_,row) =>if row==0 {luma(150)} else if calc.odd(row) { luma(220)} else {white}, [*Membro*],[*Re*],[*Am*],[*An*],[*Pt*],[*Pr*],[*Ve*],[*Ore totali per membro*], [<NAME>],[9],[15],[10],[9],[23],[26],[92], [<NAME>],[9],[14],[8],[11],[22],[29],[93], [<NAME>],[8],[16],[9],[10],[23],[27],[93], [<NAME>],[15],[13],[9],[9],[22],[25],[93], [<NAME>],[11.5],[14],[6.5],[10],[23],[27],[92], [<NAME>],[10],[14],[8],[10],[24],[26],[92], [*Ore totali per ruolo*],[62.5],[86],[50.5],[59],[137],[160],[*555*], ), caption: [Ore utilizzate per ruolo da ogni componente del team.] ) Si riporta, infine, il budget utilizzato per ruolo da parte di ogni componente del team #team rispetto a quello preventivato per lo svolgimento di #glossary[RTB] e #glossary[PB]: #figure( table( columns:(auto,auto,auto,auto,auto,auto,auto,auto), align: (x, y) => (center,center,center,center,center,center,center,center).at(x), fill:(_,row) =>if row==0 {luma(150)} else if calc.odd(row) { luma(220)} else {white}, [*Membro*],[*Re*],[*Am*],[*An*],[*Pt*],[*Pr*],[*Ve*],[*Totale per membro (€)*], [<NAME>],[270],[300],[250],[225],[345],[390],[1780], [<NAME>],[270],[280],[200],[275],[330],[435],[1790], [<NAME>],[240],[320],[225],[250],[345],[405],[1785], [<NAME>],[450],[260],[225],[225],[330],[375],[1865], [<NAME>],[345],[280],[162.5],[250],[345],[405],[1787.5], [<NAME>],[300],[280],[200],[250],[360],[390],[1780], [*Costo totale per ruolo*],[1875],[1720],[1262.5],[1475],[2055],[2400],[*10,787.5*], ), caption: [Budget utilizzato per ruolo da ogni componente del team.] )
https://github.com/jackkyyh/ZXCSS
https://raw.githubusercontent.com/jackkyyh/ZXCSS/main/scripts/4_morph.typ
typst
#import "../import.typ": * #slide(title: "Code morphing")[ #write_footer[<NAME>., & <NAME>. (2022). Morphing quantum codes. PRX Quantum, 3(3), 030319] // #pause Given a *parent code* $cal(C)_("parent")$, with stabilizers $cal(S)$ and physical qubits $Q$, Choose a subset $R subset Q$. #pause / child code: $cal(C)_("child")$ whose stabilizers are $ cal(S)_("child"):={S in cal(S): op("supp")(S) subset R}. $ ] #slide(title: "Code morphing")[ Consider the encoders $E_("parent")$ and $E_("child")$, / morphed code: $cal(C)_("morphed")$ whose encoder is $ E_("morphed"):= (I^(times.circle|Q backslash R|)times.circle E^dagger_("child"))E_("parent"). $ ] #slide(title: "Code morphing")[ #stean_arrows #stean_reprs #pause #place(dx: -13pt, dy: -10pt)[#ellipse(width: 180pt, height: 130pt, stroke: 3pt+red)] #pause #place(dx: 570pt, dy: -80pt)[#ellipse(width: 200pt, height: 210pt, stroke: 3pt+red)] ] #slide(title: "Code morphing")[ #reset_footer() #grid(columns: (21em, auto))[ Given an encoder $E_("parent") $ and a subset $R subset Q$, #alternatives[][ #box(width: 19em)[1. Unfuse all #text(olive)[green] spiders whose legs span across the boundary of $R$.]][ #box(width: 19em)[2. Add an identity #text(red)[red] spider between each pair of unfused #text(olive)[green] spiders.]][ #box(width: 22em)[3. let #text(purple)[$E_("child")$] be the subdiagram enclosed by $R$;\ let #text(blue)[$E_("morphed")$] be the subdiagram enclosed by $Q backslash R$]] ][ #alternatives(position: top+center)[ #h(60pt)#text(purple)[$R={2,3,6,7}$] #image("../figs/morph/2367/1.svg", width: 8em) #h(90pt)$E_("parent")$][ #image("../figs/morph/2367/2-0.svg", width: 8em)][ #image("../figs/morph/2367/2.svg", width: 8em)][ #image("../figs/morph/2367/3.svg", width: 9em)] ] ] #slide(title: [Code morphing])[ #place()[#text(purple)[$R={2,3,6,7}$]] #set align(center) #box[#alternatives[$E_("parent")$][$E_("steane")$]] #box(baseline: 50%)[#image("../figs/morph/2367/1.svg", height: 200pt)] #h(10pt)$=$#h(10pt) #box(baseline: 50%)[#image("../figs/morph/2367/3.svg", height: 300pt)] #box[ #place(dy: -100pt)[#text(purple)[#alternatives[$E_("child")$][$E_([| 4, 2, 2 |])$]]] #place(dy: 80pt)[#text(blue)[#alternatives[$E_("morphed")$][$E_([| 5, 1, 3 |])$]]]] ] #slide(title: [Code morphing])[ #text(purple)[$R={4,5,6,7}$] // #set align(center) #one-by-one(start: 1)[ #box(image("../figs/morph/4567/1.svg", width: 170pt), baseline: 50%) #box(place(dx:-5em, dy: 4em)[$E_"steane"$])][ $=$ #box(image("../figs/morph/4567/2.svg", width: 220pt), baseline: 40%)][ $=$ #box(image("../figs/morph/4567/3.svg", width: 270pt), baseline: 40%) #box()[ #place(dx: -10em, dy: 4em)[$E_([| 6, 1, 1 |])$] #place(dx: -5em, dy: 4em)[$E_([| 4, 3, 1 |])$]] ] ] #slide(title: [Code morphing])[ #image("../figs/morph/qrm.svg", width: 650pt) #h(100pt)$E_("QRM")$ #h(150pt)$E_([| 8, 3, 2 |])$ #h(90pt)$E_([| 10, 1, 2 |])$ ]
https://github.com/DaAlbrecht/lecture-notes
https://raw.githubusercontent.com/DaAlbrecht/lecture-notes/main/discrete_mathematics/discrete_mathematics.typ
typst
MIT License
#import "../template.typ": * #show: project.with(title: "Discrete Mathematics", header:"Discrete Mathematics") #include "./glossary-of-mathematical-symbols.typ" #pagebreak() #include "./relation.typ" #pagebreak() #include "./modular_arithmetic.typ" #pagebreak() #include "./greatest-common-divisor.typ" #pagebreak() #include "./graph_theory.typ"
https://github.com/LDemetrios/TypstParserCombinators
https://raw.githubusercontent.com/LDemetrios/TypstParserCombinators/master/README.md
markdown
Proof of concept of parser combinators in Typst.
https://github.com/alberto-lazari/cns-report
https://raw.githubusercontent.com/alberto-lazari/cns-report/main/our-approach.typ
typst
= Our Approach <our_approach> We managed to solve the critical aspects described in the previous section by implementing several key solutions. == Virtualizing the device Instead of relying on physical smartphones, we employ virtualization techniques. This eliminates the need for physical devices and monitors, thus improving scalability. == Virtualizing the camera By virtualizing the camera, we create simulated camera interfaces within the testing environment. This allows us to present QR codes for scanning without the limitations imposed by physical camera hardware. == Rewriting the QR Code Generator We rewrote the QR Code Generator component in Javascript in order to avoid comunication through the file system with the QR Code Fuzzer which was already written in Javascript. == Automation Automation plays a crucial role in the testing process. We implemented several scripts for initiating the whole environment, virtualizing the camera and running the tests in a completely automated way. == Workflow improvement The workflow of the whole system (@new_workflow) has been improved, we can identify five key phases in it: 1. The QR Code Fuzzer component takes a string as input from a pool of inputs. Using this input string, the QR Code Fuzzer generates a QR code corresponding to the string. Once generated, the QR code is saved in the file system as an image file. 2. The QR code image file saved in the file system is displayed in a virtual camera. 3. QR Code Fuzzer sends a scan request to the Android emulator through the Appium server. 4. The Android emulator receives the scan request from the Appium server, it then accesses the virtual camera where the QR code is displayed and scans the QR code. 5. Once the QR code is successfully scanned by the Android emulator, it generates a scan response which contains log informations and a screenshot. Also in this phase, the communication between the Android emulator and the QR Code Fuzzer occurs through the Appium server. #figure( image("images/architecture.png"), caption: [New architecture] ) <new_workflow>
https://github.com/christophermanning/typst-docker
https://raw.githubusercontent.com/christophermanning/typst-docker/main/README.md
markdown
MIT License
# typst-docker Run [Typst](https://github.com/typst/typst) in Docker to recursively watch and compile `*.typ` files. ## Running ``` make up ``` ## Examples [![hello-world](examples/hello-world.png)](examples/hello-world.typ) | [![resume](examples/resume.png)](examples/resume.typ) -- | --
https://github.com/Leedehai/typst-physics
https://raw.githubusercontent.com/Leedehai/typst-physics/master/README.md
markdown
MIT License
:green_book: The [manual](https://github.com/Leedehai/typst-physics/blob/v0.9.3/physica-manual.pdf). <p align="center"> <img width="545" alt="logo" src="https://github.com/Leedehai/typst-physics/assets/18319900/ed86198a-8ddb-4473-aed3-8111d5ecde60"> </p> # The physica package for Typst (v0.9.3) [![CI](https://github.com/Leedehai/typst-physics/actions/workflows/ci.yml/badge.svg)](https://github.com/Leedehai/typst-physics/actions/workflows/ci.yml) [![Latest release](https://img.shields.io/github/v/release/Leedehai/typst-physics.svg?color=gold)][latest-release] Available in the collection of [Typst packages](https://typst.app/docs/packages/): `#import "@preview/physica:0.9.3": *` > physica _noun_. > * Latin, study of nature This [Typst](https://typst.app) package provides handy typesetting utilities for natural sciences, including: * Braces, * Vectors and vector fields, * Matrices, including Jacobian and Hessian, * Smartly render `..^T` as transpose and `..^+` as dagger (conjugate transpose), * Dirac braket notations, * Common math functions, * Differentials and derivatives, including partial derivatives of mixed orders with automatic order summation, * Familiar "h-bar", tensor abstract index notations, isotopes, Taylor series term, * Signal sequences i.e. digital timing diagrams. ## A quick look See the [manual](https://github.com/Leedehai/typst-physics/blob/v0.9.3/physica-manual.pdf) for more details and examples. ![demo-quick](https://github.com/Leedehai/typst-physics/assets/18319900/4a9f40df-f753-4324-8114-c682d270e9c7) A larger [demo.typ](https://github.com/Leedehai/typst-physics/blob/master/demo.typ): ![demo-larger](https://github.com/Leedehai/typst-physics/assets/18319900/75b94ef8-cc98-434f-be5f-bfac1ef6aef9) ## Using physica in your Typst document ### With `typst` package management (recommended) See https://github.com/typst/packages. If you are using the Typst's web app, packages listed there are readily available; if you are using the Typst compiler locally, it downloads packages on-demand and caches them on-disk, see [here](https://github.com/typst/packages#downloads) for details. <p align="center"> <img src="https://github.com/Leedehai/typst-physics/assets/18319900/f2a3a2bd-3ef7-4383-ab92-9a71affb4e12" width="173" alt="effect"> </p> ```typst // Style 1 #import "@preview/physica:0.9.3": * $ curl (grad f), tensor(T, -mu, +nu), pdv(f,x,y,[1,2]) $ ``` ```typst // Style 2 #import "@preview/physica:0.9.3": curl, grad, tensor, pdv $ curl (grad f), tensor(T, -mu, +nu), pdv(f,x,y,[1,2]) $ ``` ```typst // Style 3 #import "@preview/physica:0.9.3" $ physica.curl (physica.grad f), physica.tensor(T, -mu, +nu), physica.pdv(f,x,y,[1,2]) $ ``` ### Without `typst` package management Similar to examples above, but import with the undecorated file path like `"physica.typ"`. ## Typst version The version requirement for the compiler is in [typst.toml](typst.toml)'s `compiler` field. If you are using an unsupported Typst version, the compiler will throw an error. You may want to update your compiler with `typst update`, or choose an earlier version of the `physica` package. Developed with compiler version: ```sh $ typst --version typst 0.10.0 (70ca0d25) ``` ## Manual See the [manual](https://github.com/Leedehai/typst-physics/blob/v0.9.3/physica-manual.pdf) for a more comprehensive coverage, a PDF file generated directly with the [Typst](https://typst.app) binary. To regenerate the manual, use command ```sh typst watch physica-manual.typ ``` ## Contribution * Bug fixes are welcome! * New features: welcome as well. If it is small, feel free to create a pull request. If it is large, the best first step is creating an issue and let us explore the design together. Some features might warrant a package on its own. * Testing: currently testing is done by closely inspecting the generated [manual](https://github.com/Leedehai/typst-physics/blob/v0.9.3/physica-manual.pdf). This does not scale well. I plan to add programmatic testing by comparing rendered pictures with golden images. ## Change log [changelog.md](https://github.com/Leedehai/typst-physics/blob/v0.9.3/changelog.md). ## License * Code: the [MIT License](LICENSE.txt). * Docs: the [Creative Commons BY-ND 4.0 license](https://creativecommons.org/licenses/by-nd/4.0/). [latest-release]: https://github.com/Leedehai/typst-physics/releases/latest "The latest release"
https://github.com/isaacholt100/isaacholt
https://raw.githubusercontent.com/isaacholt100/isaacholt/main/public/maths-notes/4-cambridge%3A-part-III/logic-and-computability/logic-and-computability.typ
typst
MIT License
#import "../../template.typ": * #show: doc => template(doc, hidden: (), slides: false) #let proves = sym.tack.r #let satisfies = sym.tack.r.double #let False = sym.perp = Non-classical logic == Intuitionistic logic Idea: a statement is true if there is a proof of it. A proof of $phi => psi$ is a "procedure" that can convert a proof of $phi$ to a proof of $psi$. A proof of $not phi$ is a proof that there is no proof of $phi$. In particular, $not not phi$ is not always the same as $phi$. #fact[ The Law of Excluded Middle (LEM) ($phi or not phi$) is not (generally) intuitionistically valid. ] Moreover, the Axiom of Choice is incompatible with intuitionistic set theory. In intuitionistic logic, $exists$ means an explicit element can be found. Why bother with intuitionistic logic? - Intuitionistic mathematics is more general, as we assume less (no LEM or AC). - Several notions that are conflated in classical mathematics are genuinely different constructively. - Intuitionistic proofs have a computable content that may be absent in classical proofs. - Intuitionistic logic is the internal logic of an arbitrary topos. We will inductively define a provability relation by enforcing rules that implement the BHK-interpretation. #let Proof(..content) = figure(table( columns: (auto,), inset: 8pt, align: horizon, stroke: (x, y) => if y == 0 { none } else {(top: 1pt + black, right: none, left: none, bottom: none)}, ..content )) #definition[ A set is *inhabited* if there is a proof that it is non-empty. ]<def:set.inhabited> #axiom(name: "Choice - Intutionistic Version")[ Any family of inhabited sets admits a choice function. ]<axm:choice> #theorem(name: "Diaconescu")[ The Law of Excluded Middle can be intutionistically deduced from the Axiom of Choice. ]<thm:diaconescu> #proofhints[ - Proof should use Axioms of Separation, Extensionality and Choice. - For proposition $phi$, consider $A = {x in {0, 1}: phi or (x = 0)}$ and $B = {x in {0, 1}: phi or (x = 1)}$. - Show that we have a proof of $f(A) = 0 or f(A) = 1$, similarly for $f(B)$. - Consider the possibilities that arise from above, show that they lead to either a proof of $phi$ or a proof of $not phi$. ] #proof[ - Let $phi$ be a proposition. By the Axiom of Separation, the following are sets: $ A & = {x in {0, 1}: phi or (x = 0)}, \ B & = {x in {0, 1}: phi or (x = 1)}. $ - Since $0 in A$ and $1 in B$, we have a proof that ${A, B}$ is a family of inhabited sets, thus admits a choice function $f: {A, B} -> A union B$ by the Axiom of Choice. - $f$ satisfies $f(A) in A$ and $f(B) in B$ by definition. - So we have $f(A) = 0$ or $phi$ is true, and $f(B) = 1$ or $phi$ is true. Also, $f(A), f(B) in {0, 1}$. - Now $f(A) in {0, 1}$ means we have a proof of $f(A) = 0 or f(A) = 1$ and similarly for $f(B)$. - There are the following possibilities: + We have a proof that $f(A) = 1$, so $phi or (1 = 0)$ has a proof, so we must have a proof of $phi$. + We have a proof that $f(B) = 0$, so $phi or (0 = 1)$ has a proof, so we must have a proof of $phi$. + We have a proof that $f(A) = 0 and f(B) = 1$, in which case we can prove $not phi$: assume there is a proof of $phi$, we can prove that $A = B$ (by the Axiom of Extensionality), in which case $0 = f(A) = f(B) = 1$: contradiction. - So we can always specify a proof of $phi$ or a proof of $not phi$. ] #notation[ We write $Gamma proves phi$ to mean that $phi$ is a consequence of the formulae in the set $Gamma$. $Gamma$ is called the *set of hypotheses or open assumptions*. ] #notation[ Notation for assumptions and deduction. ] #definition[ The rules of the *intuitionistic propositional calculus (IPC)* are: - conjunction introduction, - conjunction elimination, - disjunction introduction, - disjunction elimination, - implication introduction, - implication elimination, - assumption, - weakening, - construction, - and for any $A$, $ (Gamma proves False)/(Gamma proves A). $ as defined below. ]<def:rules-of-ipc> #definition[ The *conjunction introduction ($and$-I)* rule: $ (Gamma proves A quad Gamma proves B)/(Gamma proves A and B). $ ]<def:conjunction-introduction> #definition[ The *conjunction elimination ($and$-E)* rule: $ (Gamma proves A)/(Gamma proves A or B), quad (Gamma proves B)/(Gamma proves A or B). $ ]<def:conjunction-elimination> #definition[ The *disjunction introduction ($or$-I)* rule: $ (Gamma proves A)/(Gamma proves A or B), quad (Gamma proves B)/(Gamma proves A or B). $ ]<def:disjunction-introduction> #definition[ The *disjunction elimination (proof by cases) ($or$-E)* rule: $ (Gamma, A proves C quad Gamma, B proves C quad Gamma proves A or B)/(Gamma proves C). $ ]<def:disjunction-elimination> #definition[ The *implication/arrow introduction ($->$-I)* rule (note the similarity to the deduction theorem): $ (Gamma, A proves B)/(Gamma proves A -> B). $ ]<def:implication-introduction> #definition[ The *implication/arrow elimination ($->$-E)* rule (note the similarity to modus ponens): $ (Gamma proves A -> B quad Gamma proves A)/(Gamma proves B). $ ]<def:implication-elimination> #definition[ The *assumption ($A x$)* rule: for any $A$, $ ()/(Gamma, A proves A) $ ]<def:assumption> #definition[ The *weakening* rule: $ (Gamma proves B)/(Gamma, A proves B). $ ]<def:weakening> #definition[ The *construction* rule: $ (Gamma, A, A proves B)/(Gamma, A proves B). $ ]<def:construction> #remark[ We obtain classical propositional logic (CPC) from IPC by adding either: - $Gamma proves A or not A$: $ ()/(Gamma proves A or not A), $ or - If $Gamma, not A proves False$, then $Gamma proves A$: $ (Gamma, not A proves False)/(Gamma proves A). $ ] #notation[ see scan ] #definition[ We obtain *intuitionistic first-order logic (IQC)* by adding the following rules to IPC for quantification: - existental inclusion, - existential elimination, - universal inclusion, - universal elimination as defined below. ]<def:rules-of-iqc> #definition[ The *existential inclusion ($exists$-I)* rule: for any term $t$, $ (Gamma proves phi[t\/x])/(Gamma proves exists x . phi(x)). $ ]<def:existential-inclusion> #definition[ The *existential elimination ($exists$-I)* rule: $ (Gamma proves exists x . phi quad Gamma, phi proves psi)/(Gamma proves psi), $ where $x$ is not free in $Gamma$ or $psi$. ]<def:existentail-elimination> #definition[ The *universal inclusion ($forall$-I)* rule: $ (Gamma proves phi)/(Gamma proves forall x . phi), $ where $x$ is not free in $Gamma$. ]<def:universal-inclusion> #definition[ The *universal exclusion ($forall$-E)* rule: $ (Gamma proves forall x . phi(x))/(Gamma proves phi[t\/x]), $ where $t$ is a term. ]<def:universal-exclusion> #definition[ We define the notion of *discharging/closing* open assumptions, which informally means that we remove them as open assumptions, and append them to the consequence by adding implications. We enclose discharged assumptions in square brackets $[]$ to indicate this, and add discharged assumptions in parentheses to the right of the proof. For example, $->$-I is written as $ (Gamma, & [A] \ & dots.v \ & B )/(Gamma proves A -> B) (A) $ ] #example[ A natural deduction proof that $A and B -> B and A$ is given below: $ (([A and B])/A quad ([A and B])/B)/((B and A)/(A and B -> B and A) (A and B)) $ ] #example[ A natural deduction proof of $phi -> (psi -> phi)$ is given below (note clearly we must use $->$-I): #Proof( $[phi] quad [psi]$, $psi -> phi$, $phi -> (psi -> phi)$ ) ] #example[ A natural deduction proof of $(phi -> (psi -> chi)) -> ((phi -> psi) -> (phi -> chi))$ (note clearly we must use $->$-I): #Proof( $[phi -> (psi -> chi)] quad [phi -> psi] quad [phi]$, $psi -> chi quad quad psi$, $chi$, $phi -> chi$, $(phi -> psi) -> (phi -> chi)$, $(phi -> (psi -> chi)) -> ((phi -> psi) -> (phi -> chi))$ ) ] #notation[ If $Gamma$ is a set of propositions, $phi$ is a proposition and $L in {"IPC", "IQC", "CPC", "CQC"}$, write $Gamma proves_L phi$ if there is a proof of $phi$ from $Gamma$ in the logic $L$. ] #lemma[ If $Gamma proves_"IPC" phi$, then $Gamma, psi proves_"IPC" phi$ for any proposition $psi$. If $p$ is a primitive proposition (doesn't contain any logical connectives or quantifiers) and $psi$ is any proposition, then $Gamma[psi\/p] proves_"IPC" phi[psi\/p]$. ] #proof[ Induction on number of lines of proof (exercise). ] == The simply typed $lambda$-calculus #definition[ The set $Pi$ of *simple types* is generated by the grammar $ Pi := U | Pi -> Pi $ where $U$ is a countable set of *type variables (primitive types)* together with an infinite set of $V$ of *variables*. So $Pi$ consists of $U$ and is closed under $->$: for any $a, b in Pi$, $a -> b in Pi$. ]<def:simple-types> #definition[ The set $Lambda_Pi$ of *simply typed $lambda$-terms* is defined by the grammar $ Lambda_Pi := V | lambda V: Pi thin . thin Lambda_Pi | Lambda_Pi med Lambda_Pi $ In the term $lambda x: tau . M$, $x$ is a variable, $tau$ is type and $M$ is a $lambda$-term. Forming terms of this form is called *$lambda$-abstraction*. Forming terms of the form $Lambda_Pi Lambda_Pi$ is called *$lambda$-application*. ]<def:simply-typed-lambda-term> #example[ The $lambda$-term $lambda x: ZZ . x^2$ should represent the function $x |-> x^2$ on $ZZ$. ] #definition[ A *context* is a set of pairs $Gamma = {x_1: tau_1, ..., x_n: tau_n}$ where the $x_i$ are distinct variables and each $tau_i$ is a type. So a context is an assignment of a type to each variable in a given set. Write $C$ for the set of all possible contexts. Given a context $Gamma in C$, write $Gamma, x: tau$ for the context $Gamma union {x: tau}$ (if $x$ does not appear in $Gamma$). The *domain* of $Gamma$ is the set of variables ${x_1, ..., x_n}$ that occur in it, and its *range*, $abs(Gamma)$, is the set of types ${tau_1, ..., tau_n}$ that it manifests. ]<def:context> #definition[ Recursively define the *typability relation* $forces subset.eq C times Lambda_Pi times Pi$ via: + For every context $Gamma$, variable $x$ not occurring in $Gamma$ and type $tau$, we have $Gamma, x: tau forces x: tau$. + For every context $Gamma$, variable $x$ not occurring in $Gamma$, types $sigma, tau in Pi$, and $lambda$-term $M$, if $Gamma, x: sigma forces M: tau$, then $Gamma forces (lambda x: sigma . M): (sigma -> t)$. + For all contexts $Gamma$, types $sigma, tau in Pi$, and terms $M, N in Lambda_Pi$, if $Gamma forces M: (sigma -> t)$ and $Gamma forces N: sigma$, then $Gamma forces (M N): tau$. ]<def:typability-relation> #notation[ We will refer to the $lambda$-calculus of $Lambda_Pi$ with this typability relation as $lambda(->)$. ] #definition[ A variable $x$ occurring in a $lambda$-abstraction $lambda x: sigma . M$ is *bound* and is *free* otherwise. A term with no free variables is called *closed*. ]<def:variable.bound-and-free> #definition[ Terms $M$ and $N$ are *$alpha$-equivalent* if they differ only in the names of their bound variables. ]<def:alpha-equivalence> #definition[ If $M$ and $N$ are $lambda$-terms and $x$ is a variable, then we define the *substitution of $N$ for $x$ in $M$* by the following rules: - $x[x := N] = N$. - $y[x := N] = y$ for $y != x$. - $(P Q)[x := N] = P[x := N] Q[x := N]$ for $lambda$-terms $P, Q$. - $(lambda y: sigma . P)[x := N] = lambda y: sigma . (P[x := N])$ for $x != y$ and $y$ not free in $N$. ]<def:substitution> #definition[ The *$beta$-reduction* relation is the smallest relation $-->_beta$ on $Lambda_Pi$ closed under the following rules: - $(lambda x: sigma . P) Q -->_beta P[x := Q]$. The term being reduced is called a *$beta$-redex*, and the result is called its *$beta$-contraction*. - If $P -->_beta P'$, then for all variables $x$ and types $sigma in Pi$, we have $lambda x: sigma . P -->_beta lambda x: sigma . P'$. - If $P -->_beta P'$ and $Z$ is a $lambda$-term, then $P Z -->_beta P' Z$ and $Z P -->_beta Z P'$. ]<def:beta-reduction> #definition[ We define *$beta$-equivalence*, $equiv_beta$, as the smallest equivalence relation containing $-->_beta$. ]<def:beta-equivalence> #example[ We have $(lambda x: ZZ . (lambda y: tau . x)) 2 -->_beta (lambda y: tau . 2)$. ] #lemma(name: "Free Variables Lemma")[ Let $Gamma forces M: sigma$. Then - If $Gamma subset.eq Gamma'$, then $Gamma' forces M: sigma$. - The free variables of $M$ occur in $Gamma$. - There is a context $Gamma^* subset.eq Gamma$ whose variables are exactly the free variables in $M$, with $Gamma^* forces M: sigma$. ]<lem:free-variables> #lemma(name: "Generation Lemma")[ + For every variable $x in V$, context $Gamma$ and type $sigma in Pi$: if $Gamma forces x: sigma$, then $x: sigma in Gamma$. + If $Gamma forces (M N): sigma$, then there is a type $tau in Pi$ such that $Gamma forces M: tau -> sigma$ and $Gamma forces N: tau$. + If $Gamma forces (lambda x . M): sigma$, then there are types $tau, rho in Pi$ such that $Gamma, x: tau forces M: rho$ and $sigma = (tau -> rho)$. ]<lem:generation> #proof[ By induction (exercise). ] #lemma(name: "Substitution Lemma")[ + If $Gamma forces M: sigma$ and $alpha in U$ is a type variable, then $Gamma[alpha := tau] forces M: sigma[alpha := tau]$. + If $Gamma, x: tau forces M: sigma$ and $Gamma forces N: tau$, then $Gamma forces M[x := N]: sigma$. ]<lem:substitution> #proposition(name: "Subject Reduction")[ If $Gamma forces M: sigma$ and $M -->_beta N$, then $Gamma forces N: sigma$. ]<prop:subject-reduction> #proof[ - By induction on the derivation of $M -->_beta N$, using Generation and Substitution Lemmas (exercise). ] #definition[ A $lambda$-term $M in Lambda_Pi$ is an *$beta$-normal form ($beta$-NF)* if there is no term $N$ such that $M -->_beta N$. ]<def:lambda-term.beta-normal-form> #notation[ Write $M ->>_beta N$ if $M$ reduces to $N$ after (potentially multiple) $beta$-reductions. ] #theorem(name: [Church-Rosser for $lambda(->)$])[ Suppose that $Gamma forces M: sigma$. If $M ->>_beta N_1$ and $M ->>_beta N_2$, then there is a $lambda$-term $L$ such that $N_1 ->>_beta L$ and $N_2 ->>_beta L$, and $Gamma: L: sigma$. ]<thm:church-rosser> #corollary(name: "Uniqueness of normal form")[ If a simply-typed $lambda$-term admits a $beta$-NF, then this form is unique. ]<cor:uniqueness-of-beta-normal-form> #proposition(name: "Uniqueness of types")[ + If $Gamma forces M: sigma$ and $Gamma forces M: tau$, then $sigma = tau$. + If $Gamma forces M: sigma$ and $Gamma forces N: tau$, and $M equiv_beta N$, then $sigma = tau$. ]<prop:uniqueness-of-types> #proof[ + Induction (exercise). + By Church-Rosser, there is a $lambda$-term $L$ which both $M$ and $N$ reduce to. By Subject Reduction, we have $Gamma forces L: sigma$ and $Gamma forces L: tau$, so $sigma = tau$ by 1. ] #example[ There is no way to assign a type to $lambda x . x x$: let $x$ be of type $tau$, then by the Generation Lemma, in order to apply $x$ to $x$, $x$ must be of type $tau -> sigma$ for some type $sigma$. But $tau != tau -> sigma$, which contradicts Uniqueness of Types. ] #definition[ The *height function* is the recursively defined map $h: Pi -> NN$ that maps all type variables $u in U$ to $0$, and a function type $sigma -> tau$ to $1 + max{h(sigma), h(tau)}$: $ h: Pi & -> NN, \ h(u) & = 0 quad forall u in U, \ h(sigma -> tau) & = 1 + max{h(sigma), h(tau)} quad forall sigma, tau in Pi. $ We extend the height function from types to redexes by taking the height of its $lambda$-abstraction. ]<def:height-function> #notation[ $(lambda x: sigma . P^tau)^(sigma -> tau)$ denotes that $P$ has type $tau$ and the $lambda$-abstraction has type $sigma -> tau$. ] #theorem(name: [Weak normalisation for $lambda(->)$])[ Let $Gamma forces M: sigma$. Then there is a finite reduction path $M := M_0 -->_beta M_1 -->_beta ... -->_beta M_n$, where $M_n$ is in $beta$-normal form. ] #proof(name: "\"Taming the Hydra\"")[ - Idea is to apply induction on the complexity of $M$. - Define a function $m: Lambda_Pi -> NN times NN$ by $ m(M) := cases( (0, 0) & "if" M "is in" beta"-NF", (h(M), "redex"(M)) & "otherwise" ) $ where $h(M)$ is the maximal height of a redex in $M$, and $"redex"(M)$ is the number of redexes in $M$ of that height. - We use induction over $omega times omega$ to show that if $M$ is typable, then it admits a reduction to $beta$-NF. - The problem is that inductions can copy redexes or create new ones, so our strategy is to always reduce the right-most redex of maximal height. - We will argue that, by following this strategy, any new redexes that we generate have a strictly lower height than the height of the redex we chose to reduce. - ]
https://github.com/Fr4nk1inCs/typreset
https://raw.githubusercontent.com/Fr4nk1inCs/typreset/master/src/styles/basic.typ
typst
MIT License
#import "../utils/font.typ": set-font #let base-style(lang: "en", body) = { // font show: set-font.with(lang: lang) // paragraph set par(linebreaks: "optimized", justify: true) // heading show heading: strong // page set page( numbering: "1", number-align: center, ) // FIX: fixes typst's list/enum rendering // See https://github.com/typst/typst/issues/1204 for more info show list.item: it => { let current-marker = if type(list.marker) == array { list.marker.at(0) } else { list.marker } let hanging-indent = measure(current-marker).width + terms.separator.amount set terms(hanging-indent: hanging-indent) if type(list.marker) == array { terms.item( current-marker, { // set the value of list.marker in a loop set list(marker: list.marker.slice(1) + (list.marker.at(0),)) it.body }, ) } else { terms.item(current-marker, it.body) } } let counting-symbols = "1aAiI一壹あいアイא가ㄱ*" let consume-regex = regex("[^" + counting-symbols + "]*[" + counting-symbols + "][^" + counting-symbols + "]*") show enum.item: it => { if it.number == none { return it } let new-numbering = if type(enum.numbering) == function or enum.full { numbering.with(enum.numbering, it.number) } else { enum.numbering.trim(consume-regex, at: start, repeat: false) } let current-number = numbering(enum.numbering, it.number) let hanging-indent = measure(current-number).width + terms.separator.amount set terms(hanging-indent: hanging-indent) terms.item( strong(delta: -300, numbering(enum.numbering, it.number)), { if new-numbering != "" { set enum(numbering: new-numbering) it.body } else { it.body } }, ) } body }
https://github.com/pranphy/tymer
https://raw.githubusercontent.com/pranphy/tymer/main/tymer.typ
typst
MIT License
// ============================== // ======== GLOBAL STATE ======== // ============================== #let section = state("section", none) #let slide-ct = counter("slide-ct") #let global-theme = state("global-theme", none) #let backup-st = state("backup-st",false) #let backup-no = counter("backup-no") #let new-section(name) = section.update(name) #let Institute(full, short:none) = { ( full: full, short: if short==none { full } else { short } ) } #let alert(body,fill: orange) = { align(center,box(fill: fill.darken(20%), outset: 1em, width: 95%,radius: 10pt,align(center,body))) } #let Author(full-name, abbr:none) = { (full-name: full-name, abbr: "<NAME>") } // ================================ // ======== SLIDE CREATION ======== // ================================ #let slide( max-repetitions: 10, theme-variant: "default", override-theme: none, footer: true, ..args ) = { locate( loc => { if slide-ct.at(loc).first() > 0 {pagebreak()} }) locate( loc => { if backup-st.at(loc) { backup-no.step() } else { slide-ct.step() } let slide-content = global-theme.at(loc).at(theme-variant) if override-theme != none { slide-content = override-theme } let slide-info = args.named() let bodies = args.pos() slide-content(slide-info,bodies,footer:footer) }) } #let titlepage() = { slide(theme-variant: "title slide") } // =============================== // ======== DEFAULT THEME ======== // =============================== #let slide-number(obj) = { locate(loc => { let current = if backup-st.at(loc) { backup-no.at(loc).at(0) } else { slide-ct.at(loc).at(0) } let total = if backup-st.at(loc) { backup-no.final(loc).at(0) } else { slide-ct.final(loc).at(0) } [#(current)/#(total)] }) } #let slides-default-theme() = data => { let title-slide(slide-info, bodies,footer: false) = { if bodies.len() != 0 { panic("title slide of default theme does not support any bodies") } align(center + horizon)[ #block( stroke: ( y: 1mm + data.thm.ac), inset: 1em, breakable: false, [ #text(1.3em)[*#data.title*] \ #{ if data.subtitle != none { parbreak() text(.9em)[#data.subtitle] } } ] ) #set text(size: .8em) #grid( columns: (1fr,) * calc.min(data.authors.len(), 3), column-gutter: 1em, row-gutter: 1em, ..data.authors ) #data.institute.full #v(1em) #data.location \ #data.date ] } let default(slide-info, bodies,content:none,footer:true) = { if bodies.len() != 1 and content == none { panic("default variant of default theme only supports one body per slide") } let body = bodies.first() let decoration(position, body) = { let border = 1mm + color let strokes = ( header: ( bottom: border ), footer: ( top: border ) ) block( stroke: strokes.at(position), width: 100%, fill: rgb("ff8d1f"), inset: .3em, text(.5em, body) ) } // header //decoration("header", section.display()) if "title" in slide-info { block( width: 100%, inset: (x: 1em, y: 0.5em), breakable: false, fill: data.thm.bg.lighten(20%), outset: 0.6em, height: 6%, heading(level: 1, slide-info.title) ) } v(1fr) if content == none { block( width: 100%, inset: (x: 1em), breakable: false, outset: 0em, body) } else { content(bodies) } v(2fr) let cbox(body,fill: orange, width: 25%, al: center) = { box(inset:(x: 2pt, y: 1pt), height: 1.1em, width: width,fill: fill, align(al,body)) } //let cbox(body,fill:none) = { body } let slide_footer() = { block(width:100%, fill: data.thm.bg.darken(20%))[ #text(fill:data.thm.fg.darken(30%), size:12pt)[ #h(0.08fr) #cbox(fill: data.thm.bg.lighten(20%),[ #(data.short-authors.at(0)) (#data.institute.short) ]) #h(1fr) //#cbox(data.date) #cbox(width: 50%, fill: none,[#text(data.thm.fg.darken(50%),data.title) ]) #h(1fr) #cbox(fill: data.thm.bg.lighten(20%),al: right,[#data.date #h(5em) #slide-number(slide-ct)])] #h(0.15fr) ] } if footer {slide_footer()} } ( "title slide": title-slide, "default": default, ) } #let backup(content) = { backup-st.update(true) slide(alert(content),footer:false) } // =================================== // ======== TEMPLATE FUNCTION ======== // =================================== #let slides( title: none, authors: none, institute: none, location: none, subtitle: none, short-title: none, short-authors: none, date: datetime.today().display(), theme: slides-default-theme(), aspect: 1.6, thm: (fg:white,bg:rgb("282a36"),ac: orange), body ) = { let asp = aspect set page( //paper: "presentation-" + aspect-ratio, width: asp*16cm, height: 16cm, margin: 0pt, fill: thm.bg ) let data = ( title: title, authors: if type(authors) == "array" { authors } else if type(authors) in ("string", "content", "none") { (authors, ) } else { panic("if not none, authors must be an array, string, or content.") }, short-authors : if type(short-authors) in ("none") { (authors,) } else if type(short-authors) == "array" { short-authors } else if type(short-authors) in ("string","content"){ (short-authors, ) } else { panic("So much panic short-authors") }, subtitle: subtitle, short-title: short-title, date: date, institute: institute, location: location, thm: thm, ) let the-theme = theme(data) global-theme.update(the-theme) set text(font: "Noto Serif", size: 20pt, fill: thm.fg) //set text(size: 20pt, fill: thm.fg) set list(marker: (text(21pt)[▶],[•], [--])) body }
https://github.com/katamyra/Notes
https://raw.githubusercontent.com/katamyra/Notes/main/Personal%20Notes/HandsOnMl/Modules/MachineLearningLandscape.typ
typst
#import "../../../template.typ": * = The Machine Learning Landscape == Types of Machine Learning systems There are many different Types of ML systems that it is often useful to classify them in broad categories based on : - Whether or not they are trained with human supervision (supervised, unsupervised, reinforcement learning) - Whether or not they can learn incrementally on the fly (online vs batch learning) - Whether they work by simply comparing new data points to old data points, or instead detect patterns in training data === (Un)Supervised Learning - Machine learning systems can be classified according to the amount and type of supervision they get during training. There are four major categories: *supervised learning, unsupervised learning, semi-supervised learning, and reinforcement learning* #definition[ In *supervised learning*, the training data you feed to the algorithm includes the desired solution, called *labels* A typical supervised learning task is *classification*. The spam filter is an example of this, where models are filled with lots of emails with their class(label) of spam/normal emails. Another task can be predict a target numeric value, such as the price of a car, known as _predictors_. This task is often called *regression*. - One example of regression is actually *logistic regression*, which is used for classification. Basically, it outputs a certain probability than an object belongs to a class. ] #example[ Important Supervised Learning Algorithms: - k-Nearest Neighbors - Linear Regression - Logistic Regression - Support Vector Machines (SVM) - Decision Trees and Random Forests - Neural Networks (_can also be unsupervised_) ] #definition[ In *unsupervised learning* the training data is unlabeled. In this case, the system tries to learn without having a teacher. ] #example[ Important Unsupervised Learning Algorithms - Clustering - K Means - DBSCAN - Hierarchical Cluster Analysis (HCA) - Anomaly detection and novelty detection - One class SVM - Isolation Forests - Visualization and dimensionality reduction - Principal Component Analysis (PCA) - Kernel PCA - Local Linear Embedding - t-distributed Stochastic Neighbor Embedding - Association rule learning - Apriori - Eclat ] For example, say you have a lot of data about your blog's visitors. You can run an unsupervised model to group them without ever giving info about what groups they are in. === Semisupervised Learning #definition[ Some algorithms can deal with partially labeled training data, usually a lot of unlabeled data and a little bit of labeled data. A good example is google photos when it detects some of your pictures faces to get the rest. ] === Reinforcement Learning #definition[ *Reinforcement Learning* has a learning system called the _agent_ that observes the environment, selects and performs actions, and gets rewards/penalties based on its actions. It then find its best strategy, called its _policy_, to get the most reward. ] === Batch Learning #definition[ In *batch learning*, the system is incapable of learning incrementally: it must be trained using all the available data. This often takes a huge amount of time and lots of computational resources, so it is often done offline, then once fully done it can be used, This is called _offline learning_. While simple, this can take many hours of training and is not often ideal, also requiring many computing hours. ] #definition[ In *online learning*, you train the system incrementally by feeding it data instances sequentially, in "mini batches". This is especially useful when you have a continuous flow of new information. ] These systems are especially good because they don't take much computation power since you don't need to retrain many times. #definition[ *Learning rate* is how fast a system should adapt to new data. If you set it too high, it will rapidly adapt but will also tend to quickly forget the old data. If it is lower, it will learn slowly but will be more receptive to remembering things and not being affected by _noise in the data_. ] === Instance vs Model-Based Learning #definition[ *Instance Based Learning* means learning something by heart and then generalizing to new cases by comparing them to learned examples using a _similarity measure_. ] #definition[ *Model Based Learning* means to build a model based on examples and use those models to make predictions. ] == Main Challenges of Machine Learning === Insufficient Quantity of Training Data Machine learning is not nearly as fast as humans at learning at a fast pace, so it takes lots of data for algorithms to work properly. Even for very simple problems, you typically need at least thousands of examples. === Non-Representative Data In order to generalize well, the training data should be representative of the new cases that you want to generalize to. === Overfitting the Training Data Sometimes models end up overgeneralizing instead, which is known as *overfitting*. This is especially often if the data set is noisy, because the model will tend to detect patterns in the noise itself which will not generalize to new instances. #definition[ *Regularizing* is the process of reducing overfitting by constraining a model by making it simpler. The amount of regularization to apply during learning can be controlled by a *hyperparameter*, which is a parameter of the learning algorithm (not the model itself), which is set prior to training and remains constant during training. ] === Underfitting the Training Data #definition[ *Underfitting* training data occurs when your model is too simple to learn the underlying structure of the data. This is common with linear models. Most solutions include: - Selecting a more powerful model, with more parameters - Feeding better features to the learning algorithm (*feature engineering*) - Reducing the constraints on the model (reducing the regularization hyperparameter) ] == Testing and Validating The only way to know how well a model will generalize to new cases is to actually try it on new cases. #note(footer: "We often leave 20% of our data for testing")[ Often, we split up our data into two sets: the training and test set. The error rate on new cases is known as the _generalization error_, and will tell you how it performs on new instances. If your training error is low but your generalization error is high, bou are overfitting the training data. ] === Hyperparameter Turning and Model Selection Often we carve out part of the testing data into a *validation set*. We then try to train different models using (testing data - validation set) and see which one works best to see what we should use. If we use *cross-validation*, we can have many small validation sets and then we can then average out all evaluations of a model for a more accurate measurement. === Data Mismatch In some cases, you only have a few representative data but lots of data in general. If you split this up between validation and testing, the training data isn't very representation. So what one can do is hold out part of the training data to use as a pseudo test set, called the *train-dev-set*. We can then test is on the train dev set to see if it is overfitting/is performing well. If it is not performing well, you need to try to address the data mismatch in some other way. Need to do Data Mismatch
https://github.com/xdoardo/co-thesis
https://raw.githubusercontent.com/xdoardo/co-thesis/master/thesis/chapters/imp/index.typ
typst
= The Imp programming language <chapter-imp> In this chapter we will go over the implementation of a simple -- but Turing complete -- imperative language called *Imp*, as described in @software-foundations. After defining its syntax, we will give rules for its semantics and show its implementation in Agda. After this introductory work, we will discuss our implementation of transformations on Imp programs. #include "./introduction.typ" #include "./semantics.typ" #include "./analysis/index.typ" #include "./related.typ"
https://github.com/KmaEE/ee
https://raw.githubusercontent.com/KmaEE/ee/main/outline2.typ
typst
#set text(font: "IBM Plex Sans") #set par(leading: 1em) = To what extent can elliptic curves be used to establish a shared secret over an insecure channel? \ === Outline 1. Describe $ZZ_p^times$ as a group\ a. Group properties: closure, invertibility, existence of identity, associativity 2. Describe the discrete log problem\ a. Go over an example 3. Describe how the discrete log problem is used for diffie-hellman key exchange 4. A sketch/example on index calculus with finite field diffie-hellman\ a. Then explain general number field sieve and how that as a special form of index calculus can speed things up. 5. Describe how elliptic curves form a group\ a. Then, how elliptic curves can also be used for diffie-hellman key exchange. 6. Formalize pollard's $rho$ algorithm, and how it can attack discrete logs for groups in general, in $O(sqrt(n))$ time. 7. Describe the use of Diffie-Hellman in the real world with the TLS 1.3 algorithm 8. Compare the performance of a single group operation in both finite field diffie-hellman and elliptic curve diffie-hellman and form conclusions 9. Comparison for space efficiency for elliptic curves, size of group elements for elliptic curves compared to finite fields. === Tentative Table of Contents 1. Group Theory\ a. Multiplicative group modulo a prime\ b. The discrete log problem 2. Finite Field Cryptography and Attacks\ a. Diffie-hellman key exchange\ b. Index Calculus\ c. General Number Field Sieve\ 3. Elliptic Curve Cryptography\ a. Elliptic curve groups\ b. Elliptic curve diffie-hellman\ c. Pollard's $rho$ algorithm\ 4. Evaluation\ a. Diffie-Hellman used in the real world: TLS 1.3\ b. Performance of group operations \ c. Comparison of space efficiecies
https://github.com/pawarherschel/typst
https://raw.githubusercontent.com/pawarherschel/typst/main/modules/projects.typ
typst
Apache License 2.0
#import "../template/template.typ": * #import "../helpers/helpers.typ": * #let SOT = yaml("../SOT.yaml") #let projects = () #if SOT.keys().contains("projects") { projects = SOT.projects } #if projects.len() != 0 { cvSection("Projects & Associations") for project in projects { let title = project.title let society = project.society let date = project.date let location = for key in project.location.keys() { let v = project.location.at(key) if key == "github" { github-link(v) } } let description = join-as-bullet-list(project.description) let tags = () if project.keys().contains("tags") { tags = project.tags } cvEntry( title: title, society: society, date: date, location: location, description: description, tags: tags ) } }
https://github.com/soul667/typst
https://raw.githubusercontent.com/soul667/typst/main/PPT/MATLAB/notes.typ
typst
#let cntrs_id = "note_cntr" #let notes = state("dict", (:)) #let note(it, note) = { locate(loc => { let pg = loc.page() let cntr = counter(cntrs_id + str(pg)) cntr.step() notes.update(dict => { let vec = () if str(pg) in dict.keys() { vec = dict.at(str(pg)) } vec.push(note) dict.insert(str(pg), vec) dict }) it + super(cntr.display()) }) } #let display() = { set text(size: 13pt) locate(loc => { let pg = loc.page() let dict = notes.final(loc) let vec = () if str(pg) in dict.keys() { vec = dict.at(str(pg)) } if vec.len() > 0 { line(length: 100%) for i in range(0, vec.len()) { [*#{i}*、 #h(-0.5em)] + h(1pt) + vec.at(i) linebreak() } } }) }
https://github.com/HPDell/typst-cineca
https://raw.githubusercontent.com/HPDell/typst-cineca/main/test/month-view.typ
typst
MIT License
#import "@preview/cineca:0.2.0": * #set page(margin: 0.5in) #let events = ( (datetime(year: 2024, month: 2, day: 1, hour: 9, minute: 0, second: 0), [Lecture]), (datetime(year: 2024, month: 2, day: 1, hour: 10, minute: 0, second: 0), [Tutorial]), (datetime(year: 2024, month: 2, day: 2, hour: 10, minute: 0, second: 0), [Meeting]), (datetime(year: 2024, month: 2, day: 10, hour: 12, minute: 0, second: 0), [Lunch]), (datetime(year: 2024, month: 2, day: 25, hour: 8, minute: 0, second: 0), [Train]), ) #calendar-month( events, sunday-first: false, template: ( month-head: (content) => strong(content) ) ) #let events2 = ( (datetime(year: 2024, month: 5, day: 1, hour: 9, minute: 0, second: 0), ([Lecture], blue)), (datetime(year: 2024, month: 5, day: 1, hour: 10, minute: 0, second: 0), ([Tutorial], red)), (datetime(year: 2024, month: 5, day: 1, hour: 11, minute: 0, second: 0), [Lab]), ) #calendar-month( events2, sunday-first: true, rows: (2em,) * 2 + (8em,), template: ( day-body: (day, events) => { show: block.with(width: 100%, height: 100%, inset: 2pt) set align(left + top) stack( spacing: 2pt, pad(bottom: 4pt, text(weight: "bold", day.display("[day]"))), ..events.map(((d, e)) => { let col = if type(e) == array and e.len() > 1 { e.at(1) } else { yellow } show: block.with( fill: col.lighten(40%), stroke: col, width: 100%, inset: 2pt, radius: 2pt ) d.display("[hour]") h(4pt) if type(e) == array { e.at(0) } else { e } }) ) } ) )
https://github.com/Sckathach/adversarial-gnn-based-ids
https://raw.githubusercontent.com/Sckathach/adversarial-gnn-based-ids/main/mini-survey/sckathach.typ
typst
#import "@preview/ctheorems:1.1.2": * #import "@preview/showybox:2.0.1": showybox #let rainbow(content, color_from: orange, color_to: purple, angle: 70deg) = { set text(fill: gradient.linear(color_from, color_to, angle: angle)) box(content) } #let celeste(x, padding: 0.7, color_from: orange, color_to: purple, angle: 70deg, amplitude: -0.5, freq: 0.4, start: 0 * calc.pi) = { x = x.split("").slice(1, -1) for i in range(x.len()) { if x.at(i) == " " { x.at(i) = h(0.3em) } else { x.at(i) = [#{text(x.at(i), fill: white) + place(x.at(i), dy: amplitude*calc.sin(freq*i + start)*1em - padding*1em)}] } } rainbow( grid(columns: x.len(), ..x), color_from: color_from, color_to: color_to, angle: angle ) } #let colors = ( "blue": rgb("#2196F3"), "teal": rgb("#00BCD4"), "red": rgb("#FF5722"), "green": rgb("#72FC3F"), "celeste": gradient.linear(orange, purple) ) #let thmtitle(t, color: rgb("#000000")) = { return text(weight: "semibold", fill: color)[#t] } #let thmname(t, color: rgb("#000000")) = { return text(fill: color)[(#t)] } #let thmtext(t, color: rgb("#000000")) = { let a = t.children if (a.at(0) == [ ]) { a.remove(0) } t = a.join() return text(font: "New Computer Modern", fill: color)[#t] } #let thmbase( identifier, head, ..blockargs, supplement: auto, padding: (top: 0.5em, bottom: 0.5em), namefmt: x => [(#x)], titlefmt: strong, bodyfmt: x => x, separator: [#h(0.1em).#h(0.2em) \ ], base: "heading", base_level: none, ) = { if supplement == auto { supplement = head } let boxfmt(name, number, body, title: auto, ..blockargs_individual) = { if not name == none { name = [ #namefmt(name)] } else { name = [] } if title == auto { title = head } if not number == none { title += " " + number } title = titlefmt(title) body = bodyfmt(body) pad( ..padding, showybox( width: 100%, radius: 0.3em, breakable: true, padding: (top: 0em, bottom: 0em), ..blockargs.named(), ..blockargs_individual.named(), [#title#name#titlefmt(separator)#body], ), ) } let auxthmenv = thmenv( identifier, base, base_level, boxfmt, ).with(supplement: supplement) return auxthmenv.with(numbering: none) } #let styled-thmbase = thmbase.with(titlefmt: thmtitle, namefmt: thmname, bodyfmt: thmtext) #let builder-thmbox(color: rgb("#000000"), ..builderargs) = styled-thmbase.with( titlefmt: thmtitle.with(color: color.darken(30%)), bodyfmt: thmtext.with(color: color.darken(70%)), namefmt: thmname.with(color: color.darken(30%)), frame: ( body-color: color.lighten(92%), border-color: color.darken(10%), thickness: 1.5pt, inset: 1.2em, radius: 0.3em, ), ..builderargs, ) #let builder-thmbox_celeste(color: rgb("#000000"), ..builderargs) = styled-thmbase.with( titlefmt: thmtitle.with(color: color.darken(30%)), bodyfmt: thmtext.with(color: color.darken(70%)), namefmt: thmname.with(color: color.darken(30%)), frame: ( body-color: color.lighten(92%), border-color: gradient.linear(orange, purple), thickness: 1.5pt, inset: 1.2em, radius: 0.3em, ), ..builderargs, ) #let builder-thmline(color: rgb("#000000"), ..builderargs) = styled-thmbase.with( titlefmt: thmtitle.with(color: color.darken(30%)), bodyfmt: thmtext.with(color: color.darken(70%)), namefmt: thmname.with(color: color.darken(30%)), frame: ( body-color: color.lighten(92%), border-color: color.darken(10%), thickness: (left: 2pt), inset: 1.2em, radius: 0em, ), ..builderargs, ) #let problem-style = builder-thmbox(color: colors.red, shadow: (offset: (x: 2pt, y: 2pt), color: luma(70%))) #let problem = problem-style("", "Problem") #let idea-style = builder-thmbox(color: colors.blue, shadow: (offset: (x: 3pt, y: 3pt), color: luma(70%))) #let idea = idea-style("", "Idea") #let definition-style = builder-thmline(color: colors.teal) #let definition = definition-style("", "Definition") #let great-style = builder-thmbox_celeste(color: purple, shadow: (offset: (x: 3pt, y: 3pt), color: luma(70%))) #let great = great-style("", rainbow("Great!", color_from: orange, color_to: purple, angle: 0deg)) #let example-style = builder-thmline(color: colors.red) #let example = example-style("", "Example").with(numbering: none) #let abstract_(body, name: none) = { thmtitle[ABSTRACT] if name != none { [ #thmname[#name]] } thmtitle[.] body h(1fr) }
https://github.com/jgm/typst-hs
https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/layout/repeat-02.typ
typst
Other
// Test empty repeat. A #box(width: 1fr, repeat[]) B
https://github.com/francescoo22/masters-thesis
https://raw.githubusercontent.com/francescoo22/masters-thesis/main/vars/kt-to-vpr-examples.typ
typst
#let intro-kt = ```kt class A( var n: Int ) fun f(x: A, y: A) { x.n = 1 y.n = 2 } fun use_f(a: A) { f(a, a) } ``` #let intro-vpr = ```vpr field n: Int method f(x: Ref, y: Ref) requires acc(x.n) && acc(y.n) { x.n := 1 y.n := 2 } method use_f(a: Ref) requires acc(a.n) { f(a, a) // verification error } ``` #let intro-kt-annotated = ```kt class A(var n: Int) fun f(@Unique @Borrowed x: A, @Unique @Borrowed y: A) { x.n = 1 y.n = 2 } fun use_f(@Unique a: A) { f(a, a) // annotations checking error } ``` #let classes-kt = ```kt open class A( val x: Int, var y: Int, ) class B( val a1: A, var a2: A, ) class C( val b: B?, ) : A(0, 0) ``` #let classes-vpr = ```vpr field x: Int field y: Int field a1: Ref field a2: Ref field b: Ref predicate SharedA(this: Ref) { acc(this.x, wildcard) } predicate SharedB(this: Ref) { acc(this.a1, wildcard) && acc(SharedA(this.a1), wildcard) } predicate SharedC(this: Ref) { acc(SharedA(this), wildcard) acc(this.b, wildcard) && (this.b != null ==> acc(SharedB(this.b), wildcard)) } ``` #let return-kt = ```kt @Unique fun returnUnique(): T { // ... } fun returnShared(): T { // ... } ``` #let return-vpr = ```vpr method returnUnique() returns(ret: Ref) ensures acc(SharedT(ret), wildcard) ensures acc(UniqueT(ret), write) method returnShared() returns(ret: Ref) ensures acc(SharedT(ret), wildcard) ``` #let param-kt = ```kt fun arg_unique( @Unique t: T ) { } fun arg_shared( t: T ) { } fun arg_unique_b( @Unique @Borrowed t: T ) { } fun arg_shared_b( @Borrowed t: T ) { } ``` #let param-vpr = ```vpr method arg_unique(t: Ref) requires acc(UniqueT(t)) requires acc(SharedT(t), wildcard) ensures acc(SharedT(t), wildcard) method arg_shared(t: Ref) requires acc(SharedT(t), wildcard) ensures acc(SharedT(t), wildcard) method arg_unique_b(t: Ref) requires acc(UniqueT(t)) requires acc(SharedT(t), wildcard) ensures acc(UniqueT(t)) ensures acc(SharedT(t), wildcard) method arg_shared_b(t: Ref) requires acc(SharedT(t), wildcard) ensures acc(SharedT(t), wildcard) ``` #let classes-unique-kt = ```kt class A( val x: Int, var y: Int, ) class B( @property:Unique val a1: A, val a2: A, ) class C( @property:Unique val b: B?, ) : A(0, 0) ``` #let classes-unique-vpr = ```vpr predicate UniqueA(this: Ref) { acc(this.x, wildcard) && acc(this.y, write) } predicate UniqueB(this: Ref) { acc(this.a1, wildcard) && acc(SharedA(this.a1), wildcard) && acc(UniqueA(this.a1), write) && acc(this.a2, wildcard) && acc(SharedA(this.a2), wildcard) && } predicate UniqueC(this: Ref) { acc(this.b, wildcard) && (this.b != null ==> acc(SharedB(this.b), wildcard)) && (this.b != null ==> acc(UniqueB(this.b), write)) && acc(UniqueA(this), write) } ``` #let full-encoding = ```vpr field bf$a1: Ref field bf$a2: Ref field bf$b: Ref field bf$x: Ref field bf$y: Ref predicate p$c$A$shared(this: Ref) { acc(this.bf$x, wildcard) && df$rt$isSubtype(df$rt$typeOf(this.bf$x), df$rt$intType()) } predicate p$c$B$shared(this: Ref) { acc(this.bf$a1, wildcard) && acc(p$c$A$shared(this.bf$a1), wildcard) && df$rt$isSubtype(df$rt$typeOf(this.bf$a1), df$rt$T$c$A()) } predicate p$c$C$shared(this: Ref) { acc(this.bf$b, wildcard) && (this.bf$b != df$rt$nullValue() ==> acc(p$c$B$shared(this.bf$b), wildcard)) && acc(p$c$A$shared(this), wildcard) && df$rt$isSubtype(df$rt$typeOf(this.bf$b), df$rt$nullable(df$rt$T$c$B())) } ``` #let param-table = table( columns: (auto, auto, auto, auto, auto), inset: 8pt, align: horizon, table.header( "", "Unique", "Unique\nBorrowed", "Shared", "Shared\nBorrowed", ), "Requires Shared Predicate", $checkmark$, $checkmark$, $checkmark$, $checkmark$, "Ensures Shared Predicate", $checkmark$, $checkmark$, $checkmark$, $checkmark$, "Requires Unique Predicate", $checkmark$, $checkmark$, "✗", "✗", "Ensures Unique Predicate", "✗", $checkmark$, "✗", "✗", ) #let receiver-kt = ```kt fun @receiver:Unique T.uniqueReceiver() {} fun @receiver:Unique @receiver:Borrowed T.uniqueBorrowedReceiver() {} ``` #let receiver-vpr = ```vpr method uniqueReceiver(this: Ref) requires acc(SharedT(this), wildcard) requires acc(UniqueT(this), write) ensures acc(SharedT(this), wildcard) method uniqueBorrowedReceiver(this: Ref) requires acc(SharedT(this), wildcard) requires acc(UniqueT(this), write) ensures acc(SharedT(this), wildcard) ensures acc(UniqueT(this), write) ``` #let unique-call-kt = ```kt fun uniqueParam( @Unique t: T ) { } fun uniqueBorrowedParam( @Unique @Borrowed t: T ) { } fun call( @Unique @Borrowed t1: T, @Unique t2: T ) { uniqueBorrowedParam(t1) uniqueBorrowedParam(t2) uniqueParam(t2) } ``` #let unique-call-vpr = ```vpr method uniqueParam(t: Ref) requires acc(UniqueT(t), write) && acc(SharedT(t), wildcard) ensures acc(SharedT(t), wildcard) method uniqueBorrowedParam(t: Ref) requires acc(UniqueT(t), write) && acc(SharedT(t), wildcard) ensures acc(UniqueT(t), write) && acc(SharedT(t), wildcard) method call(t1: Ref, t2: Ref) requires acc(UniqueT(t1), write) && acc(SharedT(t1), wildcard) requires acc(UniqueT(t2), write) && acc(SharedT(t2), wildcard) ensures acc(UniqueT(t1), write) && acc(SharedT(t1), wildcard) ensures acc(SharedT(t2), wildcard) { uniqueBorrowedParam(t1) uniqueBorrowedParam(t2) uniqueParam(t2) } ``` #let shared-call-kt = ```kt fun sharedParam( t: T ) { } fun sharedBorrowedParam( @Borrowed t: T ) { } fun call(@Unique t: T) { sharedBorrowedParam(t) sharedParam(t) } ``` #let shared-call-vpr = ```vpr method sharedParam(t: Ref) requires acc(SharedT(t), wildcard) ensures acc(SharedT(t), wildcard) method sharedBorrowedParam(t: Ref) requires acc(SharedT(t), wildcard) ensures acc(SharedT(t), wildcard) method call(t: Ref) requires acc(UniqueT(t), write) && acc(SharedT(t), wildcard) ensures acc(SharedT(t), wildcard) { exhale acc(UniqueT(t), write) sharedBorrowedParam(t) inhale acc(UniqueT(t), write) exhale acc(UniqueT(t), write) sharedParam(t) } ``` #let constructor-kt = ```kt class A(val x: Int, var y: Int) class B(@property:Unique var a1: A, var a2: A) ``` #let constructor-vpr = ```vpr method constructorA(p1: Int, p2: Int) returns (ret: Ref) ensures acc(SharedA(ret), wildcard) ensures acc(UniqueA(ret), write) ensures unfolding acc(SharedA(ret), wildcard) in ret.x == p1 ensures unfolding acc(UniqueA(ret), write) in ret.x == p1 && ret.y == p2 method constructorB(p1: Ref, p2: Ref) returns (ret: Ref) requires acc(UniqueA(p1), write) requires acc(SharedA(p1), wildcard) requires acc(SharedA(p2), wildcard) ensures acc(SharedB(ret), wildcard) ensures acc(UniqueB(ret), write) ensures unfolding acc(UniqueB(ret), write) in ret.a1 == p1 && ret.a2 == p2 ``` // ************* Chapter 5 comparison ************* #let grammar_annotations-5 = ``` class C( f1: unique, f2: shared ) m1() : unique { ... } m2(this: unique) : shared { ... } m3( x1: unique, x2: unique ♭, x3: shared, x4: shared ♭ ) { ... } ``` #let kt_annotations-5 = ```kt class C( @property:Unique var f1: Any, var f2: Any ) @Unique fun m1(): Any { /* ... */ } fun @receiver:Unique Any.m2() { /* ... */ } fun m3( @Unique x1: Any, @Unique @Borrowed x2: Any, x3: Any, @Borrowed x4: Any ) { /* ... */ } ``` #let compare-grammar-kt = align( center, figure( caption: "Comparison between the grammar and annotated Kotlin", grid( columns: (auto, auto), column-gutter: 2em, row-gutter: .5em, grammar_annotations-5, kt_annotations-5 ) ) ) #let unfold-shared-kt = ```kt class A( val n: Int ) class B( val a: A ) fun f(b: B): Int { return b.a.n } ``` #let unfold-shared-vpr = ```vpr field n: Int, a: Ref predicate SharedA(this: Ref) { acc(this.n, wildcard) } predicate SharedB(this: Ref) { acc(this.a, wildcard) && acc(SharedA(this.a), wildcard) } method f(b: Ref) returns(res: Int) requires acc(SharedB(b), wildcard) ensures acc(SharedB(b), wildcard) { unfold acc(SharedB(b), wildcard) unfold acc(SharedA(b.a), wildcard) res := b.a.n } ``` #let unfold-unique-kt = ```kt class A( var n: Int ) class B( @property:Unique var a: A ) fun f( @Unique b: B ): Int { return b.a.n } ``` #let unfold-unique-vpr = ```vpr field n: Int, a: Ref predicate UniqueA(this: Ref) { acc(this.n, write) } predicate UniqueB(this: Ref) { acc(this.a, write) && acc(UniqueA(this.a), write) } method f(b: Ref) returns(res: Int) requires acc(UniqueB(b), write) ensures acc(UniqueB(b), write) { unfold acc(UniqueB(b), write) unfold acc(UniqueA(b.a), write) res := b.a.n fold acc(UniqueA(b.a), write) fold acc(UniqueB(b), write) } ``` #let inhale-shared-kt = ```kt class A( val x: Int, var y: Int ) fun f( a: A ) { a.y = 1 } ``` #let inhale-shared-vpr = ```vpr field x: Int, y: Int predicate SharedA(this: Ref) { acc(this.x, wildcard) } method f(a: Ref) returns(res: Int) requires acc(SharedA(a), wildcard) ensures acc(SharedA(a), wildcard) { inhale acc(a.y, write) a.y := 1 exhale acc(a.y, write) } ```
https://github.com/cafeclimber/typst-psu
https://raw.githubusercontent.com/cafeclimber/typst-psu/main/psu_thesis.typ
typst
#let appendix(title) = { heading(title, supplement: "Appendix") } #let appendices(body) = { counter(heading).update(0) counter("appendices").update(1) set heading( numbering: (..nums) => { let vals = nums.pos() let value = "ABCDEFGHIJ".at(vals.at(0) - 1) if vals.len() == 1 { return value + ": " } else { return value + "." + nums.pos().slice(1).map(str).join(".") } } ); body } #let psu_thesis( title: "Title", author: (), committee_members: (), paper-size: "us-letter", bibliography-file: none, department: "Department", degree_type: "doctorate", date: ( year: "2000", month: "January", day: "01" ), body ) = { // Useful variables let doc_title = if degree_type == "doctorate" [dissertation] else [thesis] let doc_title_cap = if degree_type == "doctorate" [Dissertation] else [Thesis] let psu = "The Pennsylvania State University" let degree = { if degree_type == "doctorate" [Doctor of Philosophy] else [Master of Science] } let unit = "The Graduate School" let front_matter_sections = ( [Abstract], [Table of Contents], [List of Figures], [List of Tables], [List of Maps], [List of Abbreviations], [Preface], [Acknowledgements], [Epigraph], [Frontispiece], [Dedication], ) set document(title: title, author: author) set page( paper: paper-size, margin: 1in, ) set text(font: "HK Grotesk", size: 12pt) show heading.where(level: 1): it => { set text(18pt) if it.supplement != auto [ #it.supplement #counter(heading).display() | #it.body ] else [ #it.body ] v(0.5em) } // Title page { set page (numbering: none) set par(leading: 2em) set align(center) v(10mm) [#psu \ #unit] v(20mm) text(14pt, weight: "bold", upper(title)) v(20mm) [A #doc_title_cap in \ #department \ by \ #author] v(10mm) [#sym.copyright #date.year #author] v(10mm) par(leading: 0.65em, [ Submitted in Partial Fulfilment \ of the Requirements \ for the Degree of #v(10mm) #degree ]) v(10mm) [#date.month #date.year] } pagebreak(weak: true) // Front matter { set page(numbering: "i") // Committee Page "The " + doc_title + " of " + author + " was reviewed and approved by the following:\n" v(10mm) for member in committee_members { member.name + "\n" member.title v(12pt) } pagebreak(weak: true) heading(outlined: false)[Abstract] pagebreak(weak: true) heading(outlined: false)[Table of Contents] locate(loc => { let items = query(heading, loc) let fm = items.filter(it => it.body in front_matter_sections and it.outlined) for line in fm { line.body box(width: 1fr, repeat[.]) numbering("i", line.location().position().page) [\ ] } }) v(1em) locate(loc => { let items = query(heading, loc) let lines = items.filter(it => it.level == 1 and it.body not in front_matter_sections) for line in lines { let string = [ #if line.supplement != auto [ #line.supplement #counter(heading).at(line.location()).first() | ] #line.body #box(width: 1fr, repeat[.]) #counter(page).at(line.location()).first() \ ] if line.has("label") { link(line.label, string) } else { string } let its = query(heading, after: line.location()).slice(1) let children = () for h in its { if h.level == 1 { break } let string = [ #(" " * 4 * h.level) #h.body #box(width: 1fr, repeat[.]) #counter(page).at(h.location()).first()\ ] if h.has("label") { link(h.label, string) } else { string } } v(1em) } }) pagebreak(weak: true) // We have to add headings to these lists to include them in the overall ToC heading[List of Figures] outline(title: none, target: figure.where(kind: image)) pagebreak(weak: true) heading[List of Tables] outline(title: none, target: figure.where(kind: table)) pagebreak(weak: true) heading[Acknowledgements] pagebreak(weak: true) heading[Dedication] pagebreak(weak: true) } set page(numbering: "1") set heading(numbering: "1.1") counter(page).update(1) body }
https://github.com/lxl66566/my-college-files
https://raw.githubusercontent.com/lxl66566/my-college-files/main/信息科学与工程学院/嵌入式系统/实验/报告/3/3.typ
typst
The Unlicense
#import "../template.typ": * #show: project.with( title: "实验报告 3", authors: ( "absolutex", ) ) = 电容触摸按键实验 == 实验目的 通过STM32F429的TIM2的通道1(PA5)实现输入捕获功能,并实现一个简单的电容触摸按键,通过该按键控制灯DS1的亮灭。了解触摸按键的原理,并能针对此动作进行简单的反馈。 == 实验原理 使用检测电容充放电时间的方法来判断是否有触摸,图1中R是外接的电容充电电阻,Cs是没有触摸按下时TPAD与PCB之间的杂散电容。而Cx则是有手指按下的时候,手指与TPAD之间形成的电容。图中的开关是电容放电开关(由实际使用时,由STM32F429的IO代替)。先用开关将Cs(或C+Cx)上的电放尽,然后断开开关,让R给Cs(或Cs+Cx)充电,当没有手指触摸的时候,Cs的充电曲线如图中的A曲线。而当有手指触摸的时候,手指和TPAD之间引入了新的电容Cx,此时Cs+Cx的充电曲线如图中的B曲线。从上图可以看出,A、B两种情况下,Vc达到Vth的时间分别为Tcs和Tcs+Tcx。在本次实验中,只要能够区分Tcs和Tcs+Tcx,就已经可以实现触摸检测了,当充电时间在Tcs附近,就可以认为没有触摸,而当充电时间大于Tcs+Tx时,就认为有触摸按下(Tx为检测阀值)。 #figure( image("1.png", width: 70%), caption: [电容触摸按键原理], ) == 代码描述 #include_code_file("../代码/5.c","main.c 片段", "c") == 实验结果 在本次实验中,修改了部分代码,实现了开始时红黄两灯以较慢的速度交替发光,通过不断触摸覆铜区域,增加交替变化的频率,最终达到以不同亮度闪烁的状态,总体上实现了触摸按键增加频闪频率的功能。 == 心得体会 开始时我封装了一个以不同频率闪烁的函数,然而实际测试中发现很难接受到按键信号,因为将 `delay_ms` 放在该函数内,函数运行会阻塞主线程(外层的 `while` 循环),使传感器无法检测到按键信号。 在前期测试中有出现两灯常亮的情况,但其实是频率过快人眼不能辨别,因此需要调整参数。`temp[] = {1000, 500, 100, 50}` 和 `t > temp[stage] / delay / 4` 的具体数字是调整的结果。 = 光照&接近传感器实验外部中断实验 == 实验目的 使用STM32F429的普通IO口模拟IIC时序,来驱动AP3216C传感器模块,从而检测环境光强度(ALS)和接近距离(PS)这类环境参数,并作出反馈。 在实际使用中,还学习了LCD显示屏的使用方法。 == 实验原理 本次实验使用的环境传感器为AP3216C,这是敦南科技推出的一款三合一环境传感器,它包含了:数字环境光传感器(ALS)、接近传感器(PS)和一个红外LED(IR)。该芯片通过IIC接口和MCU连接,并支持中断(INT) 输出。AP3216C的框图如图2所示。 #figure( image("2.png", width: 70%), caption: [AP3216C 框图], ) == 代码描述 #include_code_file("../代码/6.c","main.c 片段", "c") == 实验结果 在本次的实验中,修改了部分代码,没有显示参数值,取而代之的是一个会随着光照强度和距离远近而变化面积的圆。具体表现是,当距离越近或光照强度越大时,圆半径越大.可以通过按键 _KEY_UP_ 切换检测光照和检测距离的检测模式。 == 心得体会 在 `lcd.h` 头文件中内置了许多图形&字符绘制的函数,可以多加利用;光照传感器的值是非线性的,因此用 sqrt 将其映射为相对线性值,便于观察;当绘制的圆形超出了LCD屏幕的左右边界时,根据其绘制策略,可以看到“反射”回来的“波纹”,比较有意思。
https://github.com/katamyra/Notes
https://raw.githubusercontent.com/katamyra/Notes/main/Compiled%20School%20Notes/CS2340/RequirementsEngineering.typ
typst
#import "../../template.typ": * = Requirements Engineering #definition[ Requirements Engineering, (RE) is the process of establishing the needs of *stakeholders* that are to be solved by software. ] #blockquote[ So, what is the importance of RE? ] One of the reasons that RE exists today is because of most software failures are actually caused by *poor requirement definitions*, rather than a lack of qualified resources or inadequate risk management. Software runs on some hardware and is developed for a purpose. Re is about identifying that process. However, identifying that task can often be an extremely hard task. - Sheer *complexity* of the purpose/requirements - People often don't even know what they want themselves - Multiple stakeholders can have conflicting requirements #definition()[ *Non-functional requirements*: criteria that can be used to judge the operation of a system, rather than specific behaviors. Basically, they describe how the systems performs aka. its quality, rather than what it does (actions). ] #definition[ *User Requirements*: Requirements written for customers - Often written in natural language and doesn't have any technical details *System Requirements*: Requirements written for developers - Detailed functional and non-functional requirements - Clearly and rigorously specified ] #note()[ Sometimes, you may need to prioritize some resources over others, known as #underline()[resource prioritization]. This often happens if aren't able to satisfy all the requirements so you need need to prioritize them. ]
https://github.com/jgm/typst-hs
https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/layout/par-bidi-08.typ
typst
Other
// Test setting a vertical direction. // Ref: false // Error: 16-19 text direction must be horizontal #set text(dir: ttb)
https://github.com/typst/typst-snap
https://raw.githubusercontent.com/typst/typst-snap/main/README.md
markdown
Apache License 2.0
# Typst Snap for Linux This repository serves as the uploader for the Typst Snap. Currently, this is experimental. Releases are triggered by pushes on this repository. If we decide to offer this Snap permanently, they will be triggered by a Repository Dispatch from [Typst's main repository](https://github.com/typst/typst) instead. ## Limitations Since this is an experimental release, there are some limitations: - Only `amd64` is supported - Neither the `home` nor the `removable-media` interface autoconnect ## Contributing Contributions are welcome, especially for adding more architectures and documentation. We expect `arm64` to be the most sought after `amd64`. Also let us know if you are or would be interested in using Typst as a Snap. ## License This repository is licensed as Apache 2.0.
https://github.com/fyuniv/CornellNoteTemplate
https://raw.githubusercontent.com/fyuniv/CornellNoteTemplate/main/example.typ
typst
Other
#import "template.typ": * #show: cornellnote.with( college: text(2em)[*University of ... or logo*], topic: [*Identities of Trigonometric Functions*], term: [*Fall 2023*], instructor: [*Dr. Math*] ) = Introduction #lorem(100) = Methods #lorem(100) $ a + b = gamma $ + Applying the half-angle formulas twice yields $ sin^4 (3 theta) = & (frac(1 - cos (6 theta), 2))^2\ = & 1 / 4 (1 - 2 cos (6 theta) + cos^2 (6 theta))\ = & 1 / 4 - 1 / 2 cos (6 theta) + 1 / 4 dot.op frac(1 + cos (12 theta), 2)\ = & 3 / 8 - 1 / 2 cos (6 theta) + 1 / 8 cos (12 theta). $ Note the power can also be reduced using product-to-sum identities. + We use product-to-power identities. $ &cos^2 (2 x) sin^2 x \ = & (sin x cos (2 x))^2\ = & (frac(sin (x + 2 x) + sin (x - 2 x), 2))^2\ = & 1 / 4 (sin (3 x) - sin x)^2\ = & 1 / 4 (sin (3 x) - sin x)^2\ = & 1 / 4 (sin^2 (3 x) - 2 sin (3 x) sin x + sin^2 x)\ = & 1 / 4 (frac(1 - cos (6 x), 2) - (cos (3 x - x) - cos (3 x + x)) + frac(1 - cos (2 x), 2))\ = & 1 / 4 (1 - 3 / 2 cos (2 x) + cos (4 x) - 1 / 2 cos (6 x))\ = & 1 / 4 - 3 / 8 cos (2 x) + 1 / 4 cos (4 x) - 1 / 8 cos (6 x). $ #lorem(100)]
https://github.com/Pesteves2002/devops-nixos-presentation
https://raw.githubusercontent.com/Pesteves2002/devops-nixos-presentation/master/README.md
markdown
# Compile slides `typst c slides.typ` # Create notes `polylux2pdfpx slides.typ` # Present slides `pdfpc -w both slides.pdf`
https://github.com/tedaco1/typst-example
https://raw.githubusercontent.com/tedaco1/typst-example/main/document-files/extra-file.typ
typst
MIT License
= i am an extra file == rand1 #lorem(85) == rand2 #lorem(42)
https://github.com/jgm/typst-hs
https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compute/calc-39.typ
typst
Other
// Error: 17-22 expected integer, found string #range(4, step: "one")
https://github.com/shunichironomura/iac-typst-template
https://raw.githubusercontent.com/shunichironomura/iac-typst-template/main/lib.typ
typst
MIT No Attribution
#let project( paper-code: "", title: "", abstract: [], authors: (), organizations: (), keywords: (), header: [], body, ) = { // Set the document's basic properties. set document(author: authors.map(a => a.name), title: title) set page( paper: "us-letter", header: align(center, text(8pt, header)), footer: grid( columns: (1fr, 1fr), align(left)[ #paper-code ], align(right)[ Page #counter(page).display( "1 of 1", both: true, ) ], ), ) set text(font: "Times New Roman", lang: "en", size: 10pt) // Paper code align(center)[ #block(text(paper-code)) #v(1.3em, weak: true) ] // Title row. align(center)[ #block(text(weight: 700, title)) #v(1.3em, weak: true) ] // Authors align(center)[ #authors.enumerate(start: 1).map(ia => [ #let (index, author) = ia #let author_key = numbering("a", index) #set text(weight: "bold") #box[#author.name#super(author_key)#if author.at("corresponding", default: false) { sym.ast.basic }]]).join(", ") #v(1.3em, weak: true) ] // Author affiliations align(left)[ #authors.enumerate(start: 1).map(ia => [ #let (index, author) = ia #let author_key = numbering("a", index) #set text(style: "italic") #let org = organizations.find(o => o.name == author.affiliation) #super(author_key) #org.display#if author.email != none { [, #text(style: "normal",underline[#link("mailto:" + author.email)])] } ]).join(linebreak()) #linebreak() #sym.ast.basic Corresponding Author ] v(1.3em, weak: true) // Abstract. align(center)[*Abstract*] { set par(justify: true, first-line-indent: 0.5cm) abstract } // Keywords. if keywords.len() > 6 { panic("Too many keywords. Please limit to 6.") } else if keywords.len() > 0 { [*Keywords:* #keywords.join(", ")] } v(1.3em, weak: true) // Main body. set heading(numbering: (..numbers) => if numbers.pos().len() <= 1 { numbers.pos().map(str).join(".") + "." } else { numbers.pos().map(str).join(".") }) show heading.where(level: 1): it => { { set text(size: 10pt) set heading(numbering: "1.1.1") it } let a = par(box()) a v(-0.45 * measure(2 * a).width) } show heading.where(level: 2): it => { { set text(size: 10pt, weight: "regular", style: "italic") it } let a = par(box()) a v(-0.45 * measure(2 * a).width) } show heading.where(level: 3): it => { { set text(size: 10pt, weight: "regular", style: "italic") it } let a = par(box()) a v(-0.45 * measure(2 * a).width) } // Figure show rule show figure.where(kind: image): set figure(supplement: [Fig.]) show figure.where(kind: image): it => align(center)[ #v(0.65em) #block(below: 0.65em)[#it.body] #it.supplement #it.counter.display(it.numbering). #it.caption.body #v(0.65em) ] // Table show rule show figure.where(kind: table): it => align(center)[ #v(0.65em) #it.supplement #it.counter.display(it.numbering). #it.caption.body #block(above: 0.65em)[#it.body] #v(0.65em) ] set table(stroke: (x, y) => ( left: 0pt, right: 0pt, top: if y < 1 { 1.5pt } else if y < 2 { 0.5pt } else { 0pt }, bottom: 1.5pt, )) show par: set block(spacing: 0.65em) set par(justify: true, first-line-indent: 0.5cm) show: columns.with(2, gutter: 1.3em) set math.equation(numbering: "(1)") body }
https://github.com/Akida31/anki-typst
https://raw.githubusercontent.com/Akida31/anki-typst/main/typst/src/raw.typ
typst
#import "config.typ": anki_config #import "utils.typ": assert_ty, to_plain, get_label_page, to_string /// Same as `anki_export` but takes the config. /// /// This is to remove double reads/ state dependencies. /// /// - config (dict): `anki_config` /// - id (str): The id of the card. Used to update the card later on. /// - tags (array): Tags to add to the card. /// - deck (str): Name of the card deck. Anki nests decks with `::`, so you can try `Deck::Subdeck`. /// - model (str): Name of the card model. /// - number (int, str, none): The number of the card. Not really special but passed differently to the command line interface. /// - ..fields (arguments): Additional fields for the anki card. #let _anki_export_with_config( config, id: none, tags: (), deck: none, model: none, number: none, ..fields, ) = { for tag in tags { let _ = assert_ty("tag", tag, str) } if fields.pos().len() > 0 { panic("expected only named arguments", fields.pos()) } assert(id != none) assert(deck != none) assert(model != none) let _ = assert_ty("deck", deck, str) let _ = assert_ty("model", model, str) if type(id) == content { panic("id may not be content but was " + id) } let id = str(id) let fields = fields.named() if config.export { locate(loc => { let meta = ( id: id, deck: deck, model: model, fields: (:), tags: tags, ) if config.date != none { meta.fields.insert("date", config.date) } if number != none { meta.fields.insert("number", number) } for (name, val) in fields.pairs() { let plain = to_plain(val) let spacer = "<<anki>>" let start_id = deck + id + name + "start" let end_id = deck + id + name + "end" let page_start = get_label_page(start_id, deck + "." + id, loc) let page_end = get_label_page(end_id, deck + "." + id, loc) if val == none { // ensure that duplicate ids get detected [ #[] #label(start_id) #[] #label(end_id) ] meta.fields.insert( name, none, ) } else if plain == none { [ #pagebreak(weak: true) #[] #label(start_id) #val #[] #label(end_id) ] meta.fields.insert( name, ( content: to_string(val), page_start: page_start, page_end: page_end, ), ) } else { // ensure that duplicate ids get detected [ #[] #label(start_id) #[] #label(end_id) ] meta.fields.insert( name, ( plain: plain, ), ) } } [#metadata(meta) <anki-export>] }) pagebreak(weak: true) } } /// Create an anki card. /// /// Even though the default values of `id`, `deck` and `model` are `none`, they are required! \ /// This does not create the card on its own, you have to use the command line interface! /// /// *Example* /// #example(``` /// #import anki: anki_export /// /// #anki_export( /// id: "id 29579", /// tags: ("Perfect", ), /// deck: "beauty", /// model: "simple", /// question: "Are you beautiful?", /// answer: "Yes!", /// ) /// ```, scale-preview: 100%, mode: "markup", preamble: "", scope: (_anki_export_with_config: anki.theorems.raw._anki_export_with_config), ratio: 1000) /// /// /// - id (str): The id of the card. Used to update the card later on. /// - tags (array): Tags to add to the card. /// - deck (str): Name of the card deck. Anki nests decks with `::`, so you can try `Deck::Subdeck`. /// - model (str): Name of the card model. /// - number (int, str, none): The number of the card. Not really special but passed differently to the command line interface. /// - ..fields (arguments): Additional fields for the anki card. #let anki_export( id: none, tags: (), deck: none, model: none, number: none, ..fields, ) = { anki_config.display(config => { _anki_export_with_config(config, id: id, tags: tags, deck: deck, model: model, number: number, ..fields) }) }
https://github.com/ukihot/igonna
https://raw.githubusercontent.com/ukihot/igonna/main/articles/data-science/analytics.typ
typst
== 単回帰分析 == 重回帰分析 == 最小二乗法 == 最尤法 == スプライン回帰 == ロジスティック回帰モデル == 線形判別 == フィッシャー判別 == k近傍法 == 主成分分析 == 階層的クラスタリング == 混合正規分布 == スペクトラルクラスタリング
https://github.com/ekmanib/curriculum-vitae
https://raw.githubusercontent.com/ekmanib/curriculum-vitae/main/docs/education.typ
typst
#text(font: "Jost", size: 16pt)[ Educación ] BsC. Economía, Universidad San Francisco de Quito. Quito, Ecuador, 2022. _Cum laude_. Estudiante de intercamio, Pontificia Universidad Católica de Chile. Santiago, Chile, 2021.
https://github.com/yhtq/Notes
https://raw.githubusercontent.com/yhtq/Notes/main/数学模型/论文/pkuthss-typst/contributors.typ
typst
#let contributor-link(name, url) = link(url, text(fill: blue)[#name]) #let contributors = ( TeddyHuang-00: contributor-link("@TeddyHuang-00", "https://github.com/TeddyHuang-00") )
https://github.com/sa-concept-refactoring/doc
https://raw.githubusercontent.com/sa-concept-refactoring/doc/main/chapters/personalReportJeremy.typ
typst
Contributing to an open source project as part of this SA was very exciting. I am really looking forward to our features getting merged and released as part of clangd. It was really helpful that I already have experience working with GitHub and open source projects. Actually programming was quite tedious at times due to builds taking a long time and useful functions not being easily discoverable. Also, some advanced language features could not be used, as clangd itself is using C++17. This means that, funnily enough, concepts could not be used. However, in the end, the actual code required to add the refactorings was quite simple. There was no need to adjust large configuration files, and the abstraction from the language server protocol felt at the right level. Like with most projects my biggest struggle was the documentation. What helped a lot was restructuring the outline early on. I also had a pretty hard time finding the appropriate tone to write in. My highlight was that I got to try out a new documentation tool (Typst @typst), which made writing the documentation quite a bit more fun than LaTeX. As for teamwork, Vina and I worked great together, and I had a lot of fun. Especially towards the end, when we had a great workflow with pull requests and issues to work on the project asynchronously. The weekly meetings with our advisor were also really helpful, since he has a very deep understanding of C++. In conclusion, I found the project to be a good learning experience, and I now know a lot more about the language server protocol. It feels like the time was spent well, because we were able to submit the entire work upstream, where it will hopefully live on.
https://github.com/WinstonMDP/math
https://raw.githubusercontent.com/WinstonMDP/math/main/knowledge/fields.typ
typst
#import "../cfg.typ": cfg #show: cfg = Fields $(F, +, *)$ is a field $:=$ + $(F, +, *)$ is an associative commutative ring with a unit. + $abs(F) > 1$. + All elements except zero are invertible. A field is prime $:=$ it doesn't have an own subfield. A field has exactly only one prime subfield. A finite prime subfield is isomorphic to $ZZ_p$. An infinite prime subfield is isomorhic to $QQ$. A characteristic of a field $F := cases(min n: n 1 = 0, 0)$. $(a + b)^(op("char") F) = a^(op("char") F) + b^(op("char") F)$.
https://github.com/andreasKroepelin/lovelace
https://raw.githubusercontent.com/andreasKroepelin/lovelace/main/lovelace.typ
typst
MIT License
#let line-label(it) = { if type(it) == str { it = label(it) } else if type(it) == label { // nothing } else { panic("line-label requires either a string or a label.") } metadata(( identifier: "lovelace line label", label: it )) } #let normalize-line(line) = { if type(line) == content { ( numbered: true, label: none, body: line, ) } else if type(line) == dictionary { if ("numbered", "label", "body").all(key => key in line) { line } else { panic("Pseudocode line in form of dictionary has wrong keys.") } } else if type(line) == array { line } else { panic("Pseudocode line must be content or dictionary.") } } #let indent(..children) = children.pos().map(normalize-line) #let no-number(body) = { if type(body) == content { ( numbered: false, label: none, body: body, ) } else if type(body) == dictionary { body.numbered = false body } } #let with-line-label(label, body) = { if type(body) == content { ( numbered: true, label: label, body: body, ) } else if type(body) == dictionary { body.label = label body } } #let line-number-figure(number, label, supplement, line-numbering) = { if line-numbering == none { return } counter(figure.where(kind: "lovelace-line-number")).update(number - 1) show: align.with(right + horizon) text(size: .8em, number-width: "tabular")[#numbering(line-numbering, number)] if label != none { box[ #figure( kind: "lovelace-line-number", supplement: supplement, numbering: line-numbering, none, ) #label ] } } #let half-stroke(s) = { if s == none { none } else if type(s) == stroke { ( paint: s.paint, thickness: s.thickness / 2, cap: s.cap, join: s.join, dash: s.dash, miter-limit: s.miter-limit, ) } else if type(s) == dictionary { half-stroke(stroke(s)) } } #let identify-algorithm = context { let algos = query(figure.where(kind: "algorithm").before(here())) if algos.len() > 0 { let algo = algos.last() [#algo.supplement #algo.counter.display(algo.numbering)] } } #let pseudocode( line-numbering: "1", line-number-supplement: "Line", stroke: 1pt + gray, indentation: 1em, hooks: 0pt, line-gap: .8em, booktabs-stroke: black + 2pt, booktabs: false, title: none, numbered-title: none, ..children, ) = { children = children.pos().map(normalize-line) let collect-precursors(level, line-number, y, children) = { let precursors = () for child in children { if type(child) == dictionary { let content-precursor = ( x: 2 * level, y: y, body: { set par(hanging-indent: .5em) set align(left) child.body }, numbered: child.numbered, kind: "content", ) precursors.push(content-precursor) if child.numbered { let number-precursor = ( y: y, body: line-number-figure( line-number, child.label, line-number-supplement, line-numbering ), kind: "number", ) precursors.push(number-precursor) line-number += 1 } y += 1 } else if type(child) == array { let nested-precursors = collect-precursors( level + 1, line-number, y, child ) let nested-lines = nested-precursors.filter(p => p.kind == "content") let indent-precursor = ( x: 2 * level + 1, y: y, rowspan: nested-lines.len(), kind: "indent", ) precursors.push(indent-precursor) precursors += nested-precursors line-number += nested-lines.filter(p => p.numbered).len() y += nested-lines.len() } } precursors } let precursors = collect-precursors(0, 1, 0, children) let max-x = precursors.fold(0, (curr-max, prec) => { if "x" in prec { calc.max(curr-max, prec.x) } else { curr-max } }) if numbered-title != none { if numbered-title == [] { title = strong(identify-algorithm) } else { title = [*#identify-algorithm:* #numbered-title] } } if not booktabs { booktabs-stroke = none } let line-number-correction = if line-numbering != none { 1 } else { 0 } let title-correction = if title != none { 1 } else { 1 } let cells = precursors.map(prec => { if prec.kind == "content" { grid.cell( x: prec.x + line-number-correction, y: prec.y + title-correction, colspan: max-x + 1 - prec.x, rowspan: 1, stroke: none, prec.body, ) } else if prec.kind == "number" and line-numbering != none { grid.cell( x: 0, y: prec.y + title-correction, colspan: 1, rowspan: 1, stroke: none, prec.body, ) } else if prec.kind == "indent" { grid.cell( x: prec.x + line-number-correction, y: prec.y + title-correction, colspan: 1, rowspan: prec.rowspan, stroke: (left: stroke, bottom: stroke, rest: none), h(hooks), ) } else { () } }).flatten() let max-y = cells.fold(0, (curr-max, cell) => calc.max(curr-max, cell.y)) let decoration = ( grid.header( grid.cell( x: 0, y: 0, colspan: max-x + 1 + line-number-correction, rowspan: 1, inset: if title != none { (y: .8em) } else { 0pt }, stroke: if title == none { ( top: booktabs-stroke, ) } else { ( top: booktabs-stroke, bottom: half-stroke(booktabs-stroke), ) }, align: left, title ), ), grid.footer( repeat: false, grid.cell( y: max-y + 1, colspan: max-x + 1 + line-number-correction, rowspan: 1, stroke: (top: booktabs-stroke), none ), ), ) grid( columns: max-x + 1 + line-number-correction, column-gutter: indentation / 2, row-gutter: line-gap, ..cells, ..decoration, ) } #let is-not-empty(it) = { return type(it) != content or not ( it.fields() == (:) or (it.has("children") and it.children == ()) or (it.has("children") and it.children.all(c => not is-not-empty(c))) or (it.has("text") and it.text.match(regex("^\\s*$")) != none) ) } #let unwrap-singleton(a) = { while type(a) == array and a.len() == 1 { a = a.first() } a } #let pseudocode-list(..config, body) = { let transform-list(it, numbered) = { if not it.has("children") { if numbered { return (it, ) } else { return (no-number(it), ) } } let transformed = () let non-item-child = [] let non-item-label = none let items = () for child in it.children { let f = child.func() if f in (enum.item, list.item) { items += transform-list(child.body, f == enum.item) } else if ( child.func() == metadata and child.value.at("identifier", default: "") == "lovelace line label" and "label" in child.value ) { non-item-label = child.value.label } else { non-item-child += child } } if is-not-empty(non-item-child) { if numbered { transformed.push(with-line-label(non-item-label, non-item-child)) } else { transformed.push(no-number(non-item-child)) } } if items.len() > 0 { transformed.push(indent(..items)) } transformed } let transformed = unwrap-singleton(transform-list(body, false)) if type(transformed) != array { transformed = (transformed, ) } pseudocode(..config.named(), ..transformed) }
https://github.com/taooceros/MATH-542-HW
https://raw.githubusercontent.com/taooceros/MATH-542-HW/main/HW9/HW9.typ
typst
#import "@local/homework-template:0.1.0": * // Take a look at the file `template.typ` in the file panel // to customize this template and discover how it works. #show: project.with(title: "Math 542 HW9", authors: ("<NAME>",)) = == 14.11 Suppose $f lr((x)) in bb(Z) lr([x])$ is an irreducible quartic whose splitting field has Galois group $S_4$ over $bb(Q)$ \(there are many such quartics, cf. Section 6). Let $theta$ be a root of $f lr((x))$ and set $K eq bb(Q) lr((theta))$. Prove that $K$ is an extension of $bb(Q)$ of degree 4 which has no proper subfields. Are there any Galois extensions of $bb(Q)$ of degree 4 with no proper subfields? #let Gal = $op("Gal")$ #solution[ Denote the splitting field as $L$. We know that $Gal(L|QQ(theta))$ is a subgroup of $S_4$, and since $[QQ(theta) : QQ] = 4$, $[L:QQ(theta)] = 6$, and thus by Galois correspondence, we need to go through a index $4$ subgroup. There is only one index $4$ subgroup in $S_4$, which has no additional subgroup. There aren't any Galois extension of $QQ$ of degree $4$ with no proper subfield. ] == 14.13 Prove that if the Galois group of the splitting field of a cubic over $bb(Q)$ is the cyclic group of order 3 then all the roots of the cubic are real. #solution[ The existence of complex conjugate is a order $2$ subgroup of the Galois group, which is impossible if the Galois group is $Z slash 3$. ] = 14.16 == Prove that $x^4 minus 2 x^2 minus 2$ is irreducible over $bb(Q)$. #solution[ By Eisenstein's criterion, $p=2$ divides each $a_i$ for $i<n$ while $p^2$ does not divides $2$. Thus $f$ is irreducible. ] == Show the roots of this quartic are $ alpha_1 eq sqrt(1 plus sqrt(3)) #h(2em) & alpha_3 eq minus sqrt(1 plus sqrt(3))\ alpha_2 eq sqrt(1 minus sqrt(3)) #h(2em) & alpha_4 eq minus sqrt(1 minus sqrt(3)) dot.basic $ #solution[ $ x^4 - 2x^2 - 1 &= 3\ (x^2 - 1)^2 &= 3\ x^2 - 1 &= plus.minus sqrt(3)\ $ Thus the claim follows. ] == Let $K_1 eq bb(Q) lr((alpha_1))$ and $K_2 eq bb(Q) lr((alpha_2))$. Show that $K_1 eq.not K_2$, and $K_1 sect K_2 eq bb(Q) lr((sqrt(3))) eq F$. #solution[ $K_1$ cannot be equal to $K_2$ because $K_1$ is all real, while $K_2$ is complex. Further we can see that both $K_1$ and $K_2$ contains $QQ(sqrt(3))$, while they are both degree $4$ extension, so there cannot be any intermdiate field between $K_i$ and $QQ(sqrt(3))$. ] == Prove that $K_1 comma K_2$ and $K_1 K_2$ are Galois over $F$ with $upright(G a l) lr((K_1 K_2 slash F))$ the Klein 4-group. Write out the elements of $"Gal" lr((K_1 K_2 slash F))$ explicitly. Determine all the subgroups of the Galois group and give their corresponding fixed subfields of $K_1 K_2$ containing $F$. #solution[ The Klein 4-group has four elements and corresponds to the symmetries of a rectangle. In the context of field extensions, this group would represent different automorphisms of the field $K_1 K_2$. The subgroups would then correspond to the different intermediate fields between $FF$ and $K_1 K_2$ ] == Prove that the splitting field of $x^4 minus 2 x^2 minus 2$ over $bb(Q)$ is of degree 8 with dihedral Galois group. #solution[ This involves studying the splitting field of the given polynomial and understanding its structure. The dihedral group of order 8, $D_8$ is known for its symmetries, which in the context of a Galois group, ] = \(No unexpected rational linear relations among squareroots; 10 points) == Let $K$ be a field extension of $bb(Q)$ and let $a comma b in K$. Suppose that $sqrt(a) comma sqrt(b) comma sqrt(a b) in.not K$. Show that $"Gal" lr((K lr((sqrt(a) comma sqrt(b))) slash K)) tilde.equiv bb(Z) slash 2 times bb(Z) slash 2$. #solution[ Consider the field extension $K(sqrt(a), sqrt(b))$. The Galois group $"Gal" lr((K lr((sqrt(a) comma sqrt(b))) slash K))$ consists of all automorphisms of $K lr((sqrt(a) comma sqrt(b)))$ that fix $K$. There are four such automorphisms: - Identity: Leaves both $sqrt(a)$ and $sqrt(b)$ unchanged. - Map $sqrt(a)$ to $minus sqrt(a)$ and leave $sqrt(b)$ unchanged. - Map $sqrt(b)$ to $minus sqrt(b)$ and leave $sqrt(a)$ unchanged. - Map both $sqrt(a)$ and $sqrt(b)$ to their negatives. 3. Group Structure: These automorphisms form a group isomorphic to $bb(Z) slash 2 times bb(Z) slash 2$, the direct product of two cyclic groups of order 2, representing the independent 'flipping' of $sqrt(a)$ and $sqrt(b)$. The group structure is isomorphic to $(ZZ slash 2)^2$ ] == Let $n_1 comma dots.h comma n_k$ be positive non-square integers so that, for any nonempty $S subset.eq brace.l 1 comma dots.h comma k brace.r comma product_(s in S) n_s$ is not square. Using induction, find the Galois group of $bb(Q) lr((sqrt(n_1) comma dots.h comma sqrt(n_k)))$ as an extension of $bb(Q)$. #solution[ Statement: Let $n_1 comma dots.h comma n_k$ be positive non-square integers so that, for any nonempty $S subset.eq brace.l 1 comma dots.h comma k brace.r comma product_(s in S) n_s$ is not square. Using induction, find the Galois group of $bb(Q) lr((sqrt(n_1) comma dots.h comma sqrt(n_k)))$ as an extension of $bb(Q)$. Solution: 1. Base Case: For $k eq 1$, the extension $bb(Q) lr((sqrt(n_1)))$ has Galois group $bb(Z) slash 2$, as there are two automorphisms: the identity and the map $sqrt(n_1) arrow.r minus sqrt(n_1)$. 2. Inductive Step: Assume the Galois group of $bb(Q) lr((sqrt(n_1) comma dots.h comma sqrt(n_(k minus 1))))$ is $lr((bb(Z) slash 2))^(k minus 1)$. We need to show that the Galois group of $bb(Q) lr((sqrt(n_1) comma dots.h comma sqrt(n_k)))$ is $lr((bb(Z) slash 2))^k$. 3. Extension by $sqrt(n_k)$ : The extension $bb(Q) lr((sqrt(n_1) comma dots.h comma sqrt(n_(k minus 1)) comma sqrt(n_k)))$ adds one more ’dimension’ of flipping, as $sqrt(n_k)$ can independently be mapped to its negative. 4. Conclusion: By induction, the Galois group of $bb(Q) lr((sqrt(n_1) comma dots.h comma sqrt(n_k)))$ is $lr((bb(Z) slash 2))^k$. ] == Finally, let $d_1 comma dots.h comma d_n$ be distinct squarefree integers. Show that if there is a collection of rational numbers $a_1 comma dots.h comma a_n$ so that $a_1 sqrt(d_1) plus$ $dots.h plus a_n sqrt(d_n) eq 0$, then $a_1 eq dots.h eq a_n eq 0$. #solution[ Statement: Let $d_1 comma dots.h comma d_n$ be distinct squarefree integers. Show that if there is a collection of rational numbers $a_1 comma dots.h comma a_n$ so that $a_1 sqrt(d_1) plus dots.h plus a_n sqrt(d_n) eq 0$, then $a_1 eq dots.h eq a_n eq 0$. Solution: Assume a Non-trivial Linear Combination: Assume $a_1 sqrt(d_1) plus dots.h plus a_n sqrt(d_n) eq 0$ with not all $a_i eq 0$. Galois Automorphisms: Each $sqrt(d_i)$ generates a quadratic extension of $bb(Q)$. By applying Galois automorphisms that map each $sqrt(d_i)$ independently to $minus sqrt(d_i)$, we can create equations similar to the original, but with various combinations of $sqrt(d_i)$ replaced by $minus sqrt(d_i)$. Linear Independence: Since $d_i$ ’s are distinct and squarefree, the square roots $sqrt(d_i)$ are: linearly independent over $bb(Q)$. By applying various Galois automorphisms and considering the resulting system of linear equations, we can show that the only solution to this system is $a_1 eq dots.h eq a_n eq 0$. Conclusion: Therefore, if $a_1 sqrt(d_1) plus dots.h plus a_n sqrt(d_n) eq 0$, it must be that $a_1 eq dots.h eq$ $a_n eq 0$. This concludes the proof of the linear independence of distinct squarefree ] = \(The Galois Group of $x^n minus 2 semi 15$ points): Recall that $zeta_m := exp lr((frac(2 pi i, m)))$. == Show that $bb(Q) lr((zeta_r)) sect bb(Q) lr((zeta_s)) eq bb(Q) lr((zeta_(gcd lr((r comma s)))))$. #solution[ l. Field Intersection: The intersectior $angle.l cal(Q) lr((zeta_r)) sect cal(Q) lr((zeta_s))$ is the largest field that is contained in both $bb(Q) lr((zeta_r))$ and $bb(Q) lr((zeta_s)) dot.basic$ 2. Properties of Cyclotomic Fields: $bb(Q) lr((zeta_r))$ and $bb(Q) lr((zeta_s))$ are cyclotomic fields generated by the $V^ast.basic dot.basic$ th and s-th roots of unity, respectively. The structure of these fields is closely related to the divisors of r and s. 3. The $gcd lr((r comma s)) dot.basic$ th roots of unity are contained in both $bb(Q) lr((zeta_r))$ and $bb(Q) lr((zeta_s)) comma$ since they are roots of unity of both orders. + Conclusion: Hence $bb(Q) lr((zeta_r)) sect bb(Q) lr((zeta_s))$ is exactly $QQ_lr(gcd(r comma s))$ ] == Show that $bb(Q) lr((sqrt(2)))$ is contained in $bb(Q) lr((zeta_m))$ if and only if $8 divides upright(m)$. #solution[ For $QQ(sqrt(2))$ to be contained in $QQ(zeta_m)$, observe that $zeta_8 = exp((pi i)/4)$ so that $zeta_8^2 = i$ and $zeta_8+zeta_8^7 = sqrt(2)$ . Therefore if $8 | m$ the claim follows. On the other hand since $QQ(sqrt(2)) = QQ(zeta_8)$ it follows that $8 | m$. ] == Recall that the splitting field $F$ of $x^n minus 2 in bb(Q) lr([x])$ is $bb(Q) lr((zeta_n comma root(n, 2)))$. Let $K eq bb(Q) lr((root(n, 2)))$ and let $L eq bb(Q) lr((zeta_n))$. Show that $K sect L$ is either $bb(Q)$ or $bb(Q) lr((sqrt(2)))$. \(Hint: Show that $K sect L$ is a Galois extension of $bb(Q)$. Let $m$ be its degree. Show that the constant term of the minimal polynomial of $root(n, 2)$ in $lr((K sect L)) lr([x])$ must be $root(m, 2)$. Conclude that $K sect L eq bb(Q) paren.l root(m, 2)$ and show that this is only Galois if $m in brace.l 1 comma 2 brace.r$.) #solution[ Let $m$ be the degree of $K sect L$ over $QQ$. The minimal polynomial of $root(n, 2)$ over $K sect L$ must have $root(m, 2)$ as its constant term. Since the extension is Galois, it happens only when $m = 1 "or" 2$. ] == Find $"Gal" lr((F slash bb(Q)))$ \(Hint: The Galois group sends $root(n, 2)$ to $root(n, 2) zeta_n^k$ for some $1 lt.eq k lt.eq n$ and sends $zeta_n$ to $zeta_n^ell$ for some $ell$ coprime to $k$. Use this observation to conclude that the Galois group can be identified with a subgroup of $lr((bb(Z) slash n)) times.r lr((bb(Z) slash n))^times$.) #solution[ Since the Galois group permutes the roots of $x^n -2$. We can see that it is a subgroup of $(ZZ_n ⋊ ZZ_n^times)$ where the first components correpsonds to the power of $root(n,2)$ and the second component to the power of $zeta_n$. Since the automorphism permutes the roots, we can see that it must be a subgroup of the semidirect product since it is a subgroup of the automorphism group. ] = Problem 5 \(5 points): Let $f lr((x)) eq x^4 plus 3 x^2 minus 3 x minus 2 in bb(Q) lr([x])$. Compute the prime factorization of the reduction of $f med mod med 2$ and $med mod med 3$ and use this to show that $f$ is irreducible and that the Galois group of its splitting field has order at least 12 . Using that the discriminant of this polynomial is negative, conclude that the Galois group of its splitting field is Sym\(4). #solution[ Consider $f$ over $ZZ_3[x]$ and $ZZ_2[x]$. $ f_1 = x^4 + 1\ f_2 = x^4 - x - 2 $ Since both are irreduciable, the Galois group of its splitting field acts transitively on the four roots. This implies that the order of the Galois group is a multiple of 4. Additionally, the fact that f(x)f(x) is irreducible over $QQ$ implies the Galois group acts transitively on the roots, making it a subgroup of the symmetric group $S_4$ which has order $24$. The discriminant of $f(x)$ is negative. In the context of polynomials of degree 4, a negative discriminant indicates complex roots. Since the Galois group must also include complex conjugation, this narrows it down to groups that have even permutations (as complex conjugation swaps a pair of complex roots). The only transitive subgroup of $S_4$ with order greater than 4 and which includes even permutations is $S_4$ itself. Therefore we can conclude that the Galois group of the splitting field of $f$ is $S_4$. ]
https://github.com/TycheTellsTales/typst-pho
https://raw.githubusercontent.com/TycheTellsTales/typst-pho/main/lib.typ
typst
///////////// // Imports // ///////////// #import "@preview/oxifmt:0.2.1": strfmt #import "./private.typ" as __private #import "./people.typ" #import "./boards.typ" //////////////////// // Main Functions // //////////////////// #let pho( viewer: "<NAME>", poster: "", date: "April 10th 2011", startPage: 1, endPage: 1, lambda, ) = { context { let poster = poster; // Redeclare poster so it is "in-scope" if poster == "" { poster = viewer } let pos = here().position() let key = strfmt("pho_post_{0}_{1}_{2}x{3}", poster, pos.page, calc.floor(pos.x.pt()), calc.floor(pos.y.pt()), ) let count = state(key, 0) let topic = __private.topic.with(poster: poster, date: date) let post = __private.paginator( op: poster, date: date, start: startPage, end: endPage, count, ) __private.header(username: viewer) lambda(topic, post) context { // Check if there are insufficient posts for the end of page message to be // generated. If so post it. if not __private.__tenthPost(count) { __private.pageEnd(startPage, endPage, count) } // Wrap it up with a square. __private.centerSquare() } } } #let link(body) = [ #text(green)[#body] ] #let name(name) = [#text(blue)[*\@#name*]]
https://github.com/mrtz-j/typst-thesis-template
https://raw.githubusercontent.com/mrtz-j/typst-thesis-template/main/modules/abbreviations.typ
typst
MIT License
#import "@preview/glossarium:0.5.0": print-glossary // Only print short and long, disregard rest #let custom-print-title(entry) = { let short = entry.at("short") let long = entry.at("long", default: "") [#strong(smallcaps(short)) #h(0.5em) #long] } #let abbreviations-page(abbreviations) = { // --- List of Abbreviations --- pagebreak(weak: true, to: "even") align(left)[ = List of Abbreviations #v(1em) #print-glossary( abbreviations, user-print-title: custom-print-title, // Disable back references in abbreviations list disable-back-references: true ) ] }
https://github.com/joshuabeny1999/unisg-thesis-template-typst
https://raw.githubusercontent.com/joshuabeny1999/unisg-thesis-template-typst/main/layout/disclaimer.typ
typst
Other
#let disclaimer( title: "", author: "", language: "en", submissionDate: datetime, ) = { set page( margin: (left: 30mm, right: 30mm, top: 40mm, bottom: 40mm), numbering: none, number-align: center, ) let body-font = "New Computer Modern" let sans-font = "New Computer Modern Sans" set text( font: body-font, size: 10pt, lang: "en" ) set par(leading: 1em) // --- Disclaimer --- v(10%) let title = (en: "Declaration of Authorship", de: "Eigenständigkeitserklärung") heading(title.at(language), numbering: none) let disclaimer = ( en: [ «I hereby declare, - that I have written this thesis independently, - that I have written the thesis using only the aids specified in the index; - that all parts of the thesis produced with the help of aids have been declared; - that I have handled both input and output responsibly when using AI. I confirm that I have therefore only read in public data or data released with consent and that I have checked, declared and comprehensibly referenced all results and/or other forms of AI assistance in the required form and that I am aware that I am responsible if incorrect content, violations of data protection law, copyright law or scientific misconduct (e.g. plagiarism) have also occurred unintentionally; - that I have mentioned all sources used and cited them correctly according to established academic citation rules; - that I have acquired all immaterial rights to any materials I may have used, such as images or graphics, or that these materials were created by me; - that the topic, the thesis or parts of it have not already been the object of any work or examination of another course, unless this has been expressly agreed with the faculty member in advance and is stated as such in the thesis; - that I am aware of the legal provisions regarding the publication and dissemination of parts or the entire thesis and that I comply with them accordingly; - that I am aware that my thesis can be electronically checked for plagiarism and for third-party authorship of human or technical origin and that I hereby grant the University of St. Gallen the copyright according to the Examination Regulations as far as it is necessary for the administrative actions; - that I am aware that the University will prosecute a violation of this Declaration of Authorship and that disciplinary as well as criminal consequences may result, which may lead to expulsion from the University or to the withdrawal of my title.» By submitting this thesis, I confirm through my conclusive action that I am submitting the Declaration of Authorship, that I have read and understood it, and that it is true. ], de: [ «Ich erkläre hiermit, - dass ich die vorliegende Arbeit eigenständig verfasst habe, - dass ich die Arbeit nur unter Verwendung der im Verzeichnis angegebenen Hilfsmittel verfasst habe; - dass alle mit Hilfsmitteln erbrachten Teile der Arbeit deklariert wurden; - dass ich bei der Nutzung von KI verantwortungsvoll mit dem Input wie auch mit dem Output umgegangen bin. Ich bestätige, dass ich somit nur öffentliche oder per Einwilligung freigegebene Daten eingelesen und sämtliche Resultate und/oder andere Formen von KI-Hilfeleistungen in verlangter Form überprüft, deklariert und nachvollziehbar referenziert habe und ich mir bewusst bin, dass ich die Verantwortung trage, falls es auch unbeabsichtigt zu fehlerhaften Inhalten, zu Verstössen gegen das Datenschutzrecht, Urheberrecht oder zu wissenschaftlichem Fehlverhalten (z.B. Plagiate) gekommen ist; - dass ich sämtliche verwendeten Quellen erwähnt und gemäss gängigen wissenschaftlichen Zitierregeln korrekt zitiert habe; - dass ich sämtliche immateriellen Rechte an von mir allfällig verwendeten Materialien wie Bilder oder Grafiken erworben habe oder dass diese Materialien von mir selbst erstellt wurden; - dass das Thema, die Arbeit oder Teile davon nicht bereits Gegenstand eines Leistungsnachweises einer anderen Veranstaltung oder Kurses waren, sofern dies nicht ausdrücklich mit der Referentin oder dem Referenten im Voraus vereinbart wurde und in der Arbeit ausgewiesen wird; - dass ich mir über die rechtlichen Bestimmungen zur Publikation und Weitergabe von Teilen oder der ganzen Arbeit bewusst bin und ich diese entsprechend einhalte; - dass ich mir bewusst bin, dass meine Arbeit elektronisch auf Plagiate und auf Drittautorschaft menschlichen oder technischen Ursprungs überprüft werden kann und ich hiermit der Universität St.Gallen laut Prüfungsordnung das Urheberrecht soweit einräume, wie es für die Verwaltungshandlungen notwendig ist; - Dass ich mir bewusst bin, dass die Universität einen Verstoss gegen diese Eigenständigkeitserklärung verfolgt und dass daraus disziplinarische wie auch strafrechtliche Folgen resultieren können, welche zum Ausschluss von der Universität resp. zur Titelaberkennung führen können.» Mit Einreichung der schriftlichen Arbeit stimme ich mit konkludentem Handeln zu, die Eigenständigkeitserklärung abzugeben, diese gelesen sowie verstanden zu haben und, dass sie der Wahrheit entspricht. ]) text(disclaimer.at(language)) v(15mm) grid( columns: 2, gutter: 1fr, "<NAME>, " + submissionDate.display("[day]/[month]/[year]"), author ) }
https://github.com/polarkac/MTG-Stories
https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/034%20-%20Dominaria/003_Return%20to%20Dominaria%3A%20Episode%203.typ
typst
#import "@local/mtgstory:0.2.0": conf #show: doc => conf( "Return to Dominaria: Episode 3", set_name: "Dominaria", story_date: datetime(day: 28, month: 03, year: 2018), author: "<NAME>", doc ) It had taken all day and all night, but sure enough, as Ziva promised, the morning after the merfolk had begun, Jhoira stood on the shore looking at what was left of the great skyship #emph[Weatherlight] . They were on the coast of Bogardan in a cove with a wide stretch of beach, protected by rocky outcrops on each side. Above the dunes was a flat stretch of grassy ground where the #emph[Weatherlight] now lay. Some distance inland, dark volcanic peaks rose past undulating lava fields. All that was left was the skyship's Thran metal skeleton, nearly two hundred feet long, and the bulky coils of its engines. The rest of its hull and interior had decayed away or been destroyed in the battle that had sent it to the bottom of the sea. Jhoira's mechanical owl flew over it, giving her an overhead view of the wreck through its eyes. #emph[It looks worse than it is] , Jhoira thought. She touched the locket around her neck, reminding herself that she had options, if the ship's core was more damaged than she hoped. #figure(image("003_Return to Dominaria: Episode 3/01.jpg", width: 100%), caption: [Art by Kev Walker], supplement: none, numbering: none) Between the merfolk and her human salvage crew, they had wrestled the remnant to the surface. The Tolarian supply vessel where Jhoira's diving ship was now stored had pulled the #emph[Weatherlight] into this sheltered cove, and then they had winched and levered the wreck up onto the flat ground where the restoration work could begin. The supply ship was anchored off the beach now and the salvage crew was putting up a camp near the #emph[Weatherlight] . They could start the work as early as this afternoon. The other ship anchored in the cove was Jhoira's private barque, and though much smaller and shaped like an ordinary sailing vessel, it was as much of a mechanical marvel as her diving ship. #emph[Now I just need a crew] , Jhoira thought. She missed Karn, Venser, and all the others. At least she knew where Teferi was, though there was no telling whether he could be persuaded to help or not. #emph[And there's Jodah] . Her expression turned wry. She didn't know if she could count on him, either. It had been so long since Urza's final powerful spell had all but ended the Phyrexian invasion, and Dominaria had healed so much since then. But some things would never heal. It didn't matter. Whatever happened, Jhoira would find a way. She always had before, and she didn't expect that to change anytime soon. #emph[This is too important] , she thought. Wind stirred her hair, and the angel the Church of Serra had sent her landed on the sand. Her name was Tiana, and while she seemed perfectly amiable, Jhoira had detected some air of sadness about her. But glancing at her now, Tiana looked more animated. In fact, she looked positively incandescent. Literally incandescent. Curious, Jhoira asked her, "Do you mean to be glowing like that? Is something wrong?" Her expression rapt, Tiana didn't seem to hear the question. "The shape." She gestured toward the #emph[Weatherlight] 's bare spine. "It's Gerrard's blade in the portraits." She shook her head. "Of course! I don't know why I didn't realize that before." Studying her, Jhoira pointed out, "You're not only glowing, you're smiling." Tiana dropped her gaze, suddenly self-conscious. "Sorry about the glowing. And you've seen me smile before." "Not like that." Not like someone who had lived in the dark seeing the sun for the first time. There was gravity to that smile, as if it could pull in everyone around it like a temporal anomaly. Jhoira's eyes narrowed in concern. "And now you're crying." Tiana rubbed at her face with her white sleeve. "No, it's not, I'm not . . . There's a lot of sand in the air today, I'm surprised everyone isn't crying." It had rained earlier and the sand was still damp, and the breeze had nothing in it but the salty scent of the ocean. Jhoira reached out and gently lifted Tiana's chin. She asked softly, "Why are you crying?" "I really don't know." Tiana took a deep breath, and stepped back, wiping at her face. "Seems to be going away now, whatever it is." Jhoira wasn't so sure. She looked from Tiana to the skeletal hulk of metal rising above them. This couldn't be a coincidence. When Tiana had arrived before the salvage started, she had explained that she was a guardian angel but with nothing in particular to guard, so she was available for the church's long-distance errands. Now Tiana seemed to be trying to avoid looking at the skyship, like a shy lover trying not to reveal the object of her devotion. Tiana had to be reacting to the #emph[Weatherlight] . Jhoira thought, #emph[Barely anything but her bones left, and the old girl still has it in her] . "Come on," she said. "Let's take a look at the Powerstone." #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) Hadi and the other salvagers joined Jhoira and Tiana in the Thran skeleton that was all that remained of the #emph[Weatherlight] 's hull. Hadi was the only Tolarian artificer, but the others were skilled artisans and scholars, mostly from Benalia and Jamuraa. Tien, their chief metalworker, stood beside Hadi, and she held the second most important component to this enterprise: a new hull seed Jhoira had obtained from the tree elemental Molimo. It would regrow the #emph[Weatherlight] 's hull once the artisans finished cleaning the Thran metal supports, but they still had to get the engines and other mechanical systems working. Some were magical, some not, and from the look of them, all would need a lot of work. But the first, most important component sat nestled in its metal cradle in the depths of the engine. It was the Powerstone. #figure(image("003_Return to Dominaria: Episode 3/02.jpg", width: 100%), caption: [Worn Powerstone | Art by <NAME>ginbotham], supplement: none, numbering: none) "Well, it's still here," Hadi said dubiously. "That's a good sign," Tien added, standing on tiptoe to see the teardrop-shaped crystal. "Isn't it?" Jhoira wasn't so sure. The Powerstone seemed inert. It had been created by Urza, who had collapsed Serra's Realm into the stone. Which was the reason Tiana had been sent here; the stone was a sacred object for the Church, so they had wanted an angel present to oversee its reclamation, and to return it if it no longer functioned. Jhoira had a backup plan if the stone had been destroyed or drained, but it was something she would rather hold in reserve. Jhoira had faith in the old stone. Maybe it just needed a little prodding. "What do you think?" she asked Tiana. Tiana leaned forward to study it and frowned thoughtfully. "It's intact; the connections in the cradle look good. The motivator's still attached. That's surprising after what it's been through." Hadi and Tien glanced at her in surprise. Tien said, "I didn't think angels studied mechanics." "We don't," Tiana said hastily, stepping back from the cradle as if it had burst into flame. "I don't really know anything about it." "Don't you?" Jhoira lifted her brows. This was the second time Tiana had reacted to the #emph[Weatherlight] like it was a long-lost friend. Tiana looked uncertain. "I don't think so. I've never known anything about mechanics before. But . . . it just seems obvious now." Hadi and Tien watched her with interest. Jhoira said, "This is Serra's stone. Perhaps it'll respond to you." Tiana eased forward again, more self-conscious than reluctant. "I'll try." She examined the stone for a moment more, then pressed her hands together and lowered her head. Jhoira watched her, aware everyone gathered around had stopped breathing. For a long moment nothing seemed to happen, then an inner light suffused Tiana's features. Jhoira felt the shift in the Powerstone, the moment when it came to life again. Like some powerful entity had appeared in their midst. As the stone started to glow, the others gasped and cheered. Tiana stepped back, eyes wide. Clearly she hadn't been expecting a success. As the others celebrated, Jhoira drew Tiana aside, under the shadow of the skyship's arching girders. "Forgive me, I don't think I've met an angel like you before." "You mean an angel who lacks confidence in her angelness?" Tiana's expression was wry. "It's a long story." Jhoira made her decision, partly instinct and partly a calculation based on careful observation. "Would you like to help me more than you already have?" Tiana shrugged a little, kicking at a tuft of dirt. "Sure, I don't have anything better to do. I mean, I might as well help you. Do you need me to fly somewhere for you?" "No, I need someone to supervise the reconstruction and protect the workers while I gather a crew." Jhoira smiled as Tiana went still. "Do you think you would like that?" Tiana turned to look at the engines, at the artisans who were already planning their restoration. No, Jhoira hadn't been imagining it; Tiana had an affinity for the #emph[Weatherlight] . Sounding as if her throat had gone dry, Tiana said, "Why me?" "You have the aptitude, I've seen it. And you're an angel, so I know I can trust you." Jhoira eyed her. "What do you think?" Tiana let her breath out slowly. "Yes. I think yes." #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) Gathering her crew would be a long journey, but Jhoira had planned and prepared for it, just the way she had for the #emph[Weatherlight] 's recovery. Leaving the supply ship behind, she took her barque to the coast of Jamuraa first, to the city of Suq'Ata, where previous inquiries had suggested she might find the person she was looking for. Some searching took her to the giant market of the city, where multistoried buildings of white stone with broad terraces formed a man-made canyon of warehouses, shops, offices for cargo factors, and the inns and hostels needed to house, feed, and entertain the crowds who came to do business there. Tall palm trees and flowering shrubs grew in large pots, and fountains decorated every plaza. Mechanical parrots and monkeys, similar to Jhoira's owl, guarded the goods of the open-air shops. There were people here from all over Dominaria, but the locals mostly had the brown skin and dark hair of northeastern Jamuraa, or the much darker coloring that marked Femeref and the descendants of lost Zhalfir. It was a hot afternoon and many of the merchants, their customers, and the others working in the market had stopped to have tea, honey figs, and dates under the awnings outside the various tea houses and wine bars. Jhoira was considering that herself, if she couldn't run down her quarry in the next hour. She climbed the stairs to a plaza. Water rushed down a series of fountains and falls built into the walls of a large complex of cargo offices and warehouses. People were seated under a shop's awnings, and going in and out of the big arched doorways on the two terraces above this one. Jhoira paused, trying to decide which level to search first, when sudden screams rang out from above. Everyone in the plaza and the shops around it turned to look, or froze in shock. Jhoira saw people running from a large archway two levels above and sprinted for the stairs. She reached the upper terrace in time to catch an old man who almost tumbled over the edge in his haste to get away. "What's happened?" she asked as she steadied him. "The Cabal!" he gasped. "A Cabal spy in the treasury of the Sarin Mercantile!" She set him aside and ran for the archway. Just inside, in the large open court of a cargo warehouse, two Jamuraans lay sprawled on the paving. From the alarmed yelling and the direction the others in the court were running, the fight was happening up on the roof of the warehouse. Jhoira touched the mechanical owl perched on her shoulder and whispered, "Be my eyes." It chirped and shot straight up in the air to circle above the warehouse. Jhoira split her attention between the court and her familiar's view. There was a terrace atop the warehouse roof, overlooked by a taller building with balconies. On the flat stone plane of the terrace, one woman with a sword fought half a dozen men wearing the concealing robes of desert nomads. Around them, dark magic with a demonic taint hung in the air like a fog. The swordswoman had dark skin and dark hair in a crown of braids, and was dressed in metal and leather armor. The woman's blade knocked aside a spear thrust, and she used her momentum to twist in and take a chunk out of her opponent's neck. As he collapsed, she shouted at the others, "Are you done?" A man howled in fury, his hood falling back to reveal pale skin and a shaved head marked with livid scars. #emph[A Cabal cleric] , Jhoira thought. He was using dementia magic, creating phantasms that were causing everyone else in range to run for their lives, but it clearly wasn't affecting the woman. She dispatched another cultist with a thrust to the chest and the cleric flung a death spell at her that manifested as a black orb. It struck her chest, but the woman ignored it. The owl's gaze focused in, and as the cleric cast another death burst, Jhoira spotted the faint gold light that shone around the woman as the spell struck her. #emph[Not a shield] , she thought, starting to smile. It was an immunity to magic, and she had seen it before. #figure(image("003_Return to Dominaria: Episode 3/03.jpg", width: 100%), caption: [Art by <NAME>], supplement: none, numbering: none) Jhoira had found her quarry. She called her owl back and started for the stairway. She arrived on the terrace in time to watch the woman plunge her sword into the last cultist's chest. As she was wiping the blade on his robe, several city guardsmen ran out of the nearest archway. "<NAME>!" one called out to her. "What happened here?" "What does it look like?" the woman, Shanna, called back. "Cabal agents, trying to get the merchants' route maps, so the Cabal can attack their ships and caravans. People forget they started out as common thieves in Otaria," she added as Jhoira approached her. "They do forget," Jhoira agreed. "The demon Belzenlok wants to rewrite the history of the world, with himself as the force behind every act of darkness, all the way back to the fall of the Primeval Dragons twenty thousand years ago." Shanna sheathed her sword. "You know your history." Jhoira did know her history, having caused a great deal of it herself. "And you're immune to magic. The cleric's dementia spellcasting had no effect on you." Shanna shrugged, watching her thoughtfully. "It's a family trait." "I know. I knew your ancestor, <NAME>. I see you carry her sword." Shanna went still, staring at her. All the sound and movement of the guardsmen and the growing crowd of spectators from the archways and balconies suddenly seemed far away. It was only her and Jhoira in this moment, a meeting that would be chronicled in the true history of this age. Shanna asked softly, "Who are you?" She smiled. "I'm Jhoira. I came here to find you." #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) They retreated to a wine bar on a lower level and sat on the carpets under one of the awnings. The activity in the streets and plazas slowly returned to normal around them. Shanna asked, "How did you find me?" "I've kept track of your family, and one of your cousins told me you were here in this city, following rumors of Cabal spies." Jhoira sipped her wine. "They said they miss you." Shanna set her cup aside. "I miss them. But all my life I've heard about my ancestors, and tales of lost Zhalfir. I got tired of living under the shadows of the past. I decided to make use of my inheritance." She smiled. "I have so many questions." If Shanna agreed, they would have plenty of time to discuss the past. Jhoira said, "And I have answers, but hear my question first: Would you consider serving on the #emph[Weatherlight] ?" Shanna laughed. "If it still existed, I'd consider it." Then, as she took in Jhoira's expression, her face turned sober. "I'd consider it an honor, to follow in the footsteps of my ancestor. To serve as she served. If the #emph[Weatherlight] existed." Jhoira raised her cup. "Then I would consider it an honor to have you on my crew." #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) By the time they sailed the barque to Aerona and reached Benalia City, Jhoira was even more certain she had made the right choice. Shanna wasn't Sisay reborn, but she was enough like her that at times it was almost painful for Jhoira. They spent long nights on the deck under the stars, talking, and it brought back buried memories. Jhoira was glad to have Shanna with her, but it made her miss Sisay all the more. She was expecting the same success with <NAME>, who was distantly related to <NAME>, but Danitha's answer was short and final. "No," she said. They were sitting in the garden of the Capashen townhouse, and it was late morning on a fine warm day. Birds sang in the trees and the gray stone walls sheltered the garden from the bustle of the city. "No?" Jhoira repeated. She glanced at Shanna, who had lifted her brows in startled dismay. She turned back to Danitha, whose expression was as calm and unaffected as if they were discussing their preferences for lunch. "Do you think I'm lying about who I am?" "No, I know you're Jhoira," Danitha said, still calm. She nodded to Shanna. "And you're so much like the portraits I've seen of the original Captain Sisay, I couldn't possibly deny who you are." Danitha didn't resemble Gerrard, except in her warrior bearing. Her hair was pulled back, the sides shaved to better fit under a helmet, and her face was tanned and weathered. Jhoira had known she was a knight of Benalia, but she had thought Danitha would want to follow in the steps of her famous predecessor. #figure(image("003_Return to Dominaria: Episode 3/04.jpg", width: 100%), caption: [Art by <NAME>], supplement: none, numbering: none) "Then why?" Shanna asked. She gestured to the big stone house. Danitha had come in from the stables to meet them, and her sword and shield rested just inside the double doors that were open to the main hall. "Obviously you're not afraid of a fight." "I'm a knight of Benalia," Danitha told her. "I'm sworn to defend this land." Jhoira had depended on having relatives of the two most famous #emph[Weatherlight] captains aboard. It had felt like the best way to begin the new voyages, and after meeting Shanna, she was certain she was right. She needed a Capashen. "The #emph[Weatherlight] has always been at the center of the battle, and it's time to use it to fight the Cabal, to break their hold on Dominaria. Serving with us can only help Benalia." "In the long run," Danitha agreed, still without heat. She spoke as someone absolutely certain of her own mind, which just made Jhoira want her on the crew even more. "The Cabal is attacking outlying towns and villages all around us. If I went with you, we might be fighting the Cabal halfway across the world. I want to fight them here, in my home." "I understand." Jhoira leaned back against her chair and let her breath out in resignation. #emph[I can't argue with that] , she thought. She looked at Shanna, who made a little gesture of defeat. Danitha nodded and pushed to her feet. "I need to return to my command. Stay here as long as you wish; you're both always welcome." As Danitha walked into the house, Shanna said, "Well? What next? Is there anyone else you had in mind?" "No." Jhoira wanted to slap the table in frustration, but didn't. Danitha had every right to refuse. "She was the only other I hoped to—" A young man lurched out of the house, stared at them wide-eyed, and hurried over to the table. He gasped, "What about me?" Jhoira was already on her feet, Shanna beside her, but she realized it was unlikely they were about to be attacked. He was a young man with unruly brown hair who bore a strong resemblance to Danitha. "What about you?" Shanna demanded. He explained, "I'm a Capashen. I'm Raff. I heard everything. I want to go in my sister's place." Jhoira folded her arms. This she hadn't expected. "Do you?" Shanna studied him, frowning. "How old are you?" He drew himself up. "I'm old enough to be a trained mage. I passed every exam years early and astonished my teachers with my abilities." "So they're training mages at twelve, now?" Shanna asked skeptically. "Or thirteen?" Raff lifted his chin. "Jodah of Tolaria himself said I was one of the most accomplished students he had ever seen." Up to this point, Jhoira had been a little amused, but here she drew the line. "Jodah did not say that." Raff tried to brazen it out, but a line of worry appeared between his brows. "Oh, do you know Jodah?" "Yes." Jhoira folded her arms. "From before the Phyrexian invasion." "Oh. My sister said you were that Jhoira, but—" Raff visibly deflated. "All right, Jodah didn't say that, but I'm still an incredibly accomplished mage." Jhoira shook her head and turned away. But as she and Shanna moved toward the house, Jhoira sensed magic. Raff was lucky she realized it was an illusion, not an attack. The garden had vanished and she and Shanna were suddenly standing high in the air, drifts of cloud around them. In the distance the original version of the #emph[Weatherlight] angled across the sky. The lines of its mast and hull weren't quite accurate, but it was a credible effort. Remembering Shanna's ability, she asked, "Can you see this?" "I can tell it's there, but I can see the house and the garden through it." Shanna gave Raff a thoughtful glance. "So is he any good?" #figure(image("003_Return to Dominaria: Episode 3/05.jpg", width: 100%), caption: [Art by <NAME>], supplement: none, numbering: none) Jhoira sighed and made herself evaluate Raff's skill more objectively. "He's not bad." She turned to Raff. "You've been very annoying today." The illusion vanished with a gesture. Raff said earnestly, "I won't be annoying any more, I'll be helpful. And I'm sorry for lying, I just really, really want to go with you." Frowning, Jhoira considered him. The problem was, Danitha obviously had no intention of changing her mind, which left Raff as the only option. "Give us a moment," she said, and stepped aside with Shanna. They moved away, under the willow tree close to the terrace. "What do you think?" she asked, keeping her voice low. Shanna said honestly, "I think I have scars older than that child." "True," Jhoira admitted. "But would you object to serving with him?" Shanna gave it serious consideration, her brow furrowed. "No. He's eager enough and his heart is certainly in it, and he seems to have the skills. I just . . . This will be dangerous and I'm not sure he understands that." Jhoira wasn't sure any of them understood what they were up against. She had lived so long, and seen so much, it was hard for her to imagine that someone as young as Raff would have any concept of his own mortality. But having a Capashen on the crew felt right. It felt necessary. "There is no safety while the Cabal exists. He could just as well die here fighting them." "That's true." Shanna shrugged a little. "I'm happy to serve with him if you think he'll be useful." Jhoira nodded and turned to Raff. She told him, "If you want to come, pack hurriedly. We have a long way to travel." #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) It was morning when the barque sailed into the Bogardan cove. Jhoira stood on the deck with Shanna and Raff, using a telescope to impatiently watch the shoreline. Now she lowered the scope, able to see with her own eyes the familiar shape rising above the dunes. The hull was gracefully curved, the stern mast angled backward. The railings and glass of the ports gleamed brightly. From the upright way the ship sat on the ground, it must be already partially awake and supporting itself. The #emph[Weatherlight] was whole and ready to launch. Jhoira grinned in delight. Everything had come together just as she had planned, and right on time. The camp had been disassembled, and the workers were using the small rowboats to load the last of their tools and equipment aboard the supply ship. They waved and cheered as the barque approached the shore. Shanna reached over and caught Jhoira in a one-armed hug. "I can't believe it!" Raff tried not to bounce with excitement. "There's an angel! Is that Tiana? Why does she have a vampire with her?" Jhoira and Shanna turned to stare at the figures waiting on the beach. "A what?" Jhoira said, baffled. Her plan hadn't included that. #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) As they waded through the waves and up to the sandy flat, Tiana and the vampire came to meet them. Jhoira said, "Hello, Tiana. I take it everything's gone well." She nodded to the vampire, who was clearly a vampire, except he was dressed as a knight of Benalia and no one seemed to be wary of him. "Is there anything you'd like to tell me?" Tiana tucked her wings in and scratched her head. "Well, yes. This is Arvad." Arvad dropped to his knees and offered Jhoira the pommel of his sword. "I swear to serve at your side, <NAME>." He seemed perfectly sincere. Jhoira's brows drew together. "I see." She looked at Tiana. Tiana said, "It's a long story." "I'm not sure we have time for it now." Jhoira pulled her timepiece out of her vest. "I'm expecting a—" With a rush of wind and golden light, <NAME> appeared on the shore. He gazed up at the #emph[Weatherlight] with a satisfied expression. "—a friend to arrive." Jhoira smiled. "#emph[Now] we are ready." #figure(image("003_Return to Dominaria: Episode 3/06.jpg", width: 100%), caption: [Ajani, Valiant Protector | Art by <NAME>], supplement: none, numbering: none)
https://github.com/quiode/CurriculumVitae
https://raw.githubusercontent.com/quiode/CurriculumVitae/main/resume.typ
typst
MIT License
// Generic Template for a CV, falls under the MIT License specified in the same folder as this file. #let head(name, headlines) = { heading(text(size: 1.5em, upper(name)), level: 1) v(0.3cm) par(leading: 0.8em)[ #for headline in headlines { headline.join(" " + sym.diamond.stroked + " ") linebreak() } ] } #let section(title, body) = { heading(upper(title), level: 2) line(length: 100%) pad(left: 1cm, body) } #let resume(doc, name, headlines: (), experiences: (), custom: (), avatar: none) = { set page(margin: (top: 0.6in, right: 0.75in, bottom: 0.6in, left: 0.75in)) set text(font: "New Computer Modern", size: 11pt) show raw: set text(font: "New Computer Modern Mono") align(center)[ #if avatar == none { head(name, headlines) } else { grid( columns: (8fr, 2fr), align: center, head(name, headlines), image(avatar, width: 3.5cm), ) } ] linebreak() for experience in experiences { section( experience.title, )[ #for event in experience.events { grid( columns: (2fr, 1fr), align: (left, right), strong(event.title) + if (event.location != none) { ", " + event.location }, emph( event.date.start + if (event.date.end != none) { " - " + event.date.end }, ), ) v(-5pt) grid( columns: (2fr, 1fr), align: (left, right), event.description, event.remark, ) v(0.5cm) } ] } for custom_section in custom { section(custom_section.title, custom_section.body) } // Rest of the document doc align(bottom, text(size: 0.75em)[ #line(length: 33%, stroke: 0.5pt) Quelle: #link("https://github.com/quiode/CurriculumVitae") \ Version vom #datetime.today().display("[day].[month].[year]") ]) }
https://github.com/ma4096/mvar
https://raw.githubusercontent.com/ma4096/mvar/main/typst/test.typ
typst
MIT License
#import "mvar.typ": * // a ist der namespace #let a = loadvariables("test.txt") //#let a = (b: 1, bsi: 2) Access variable via $ #a.b $ Access variable with unit: $ #a.bsi $ //#a.debug #mlogic(a.l,[Test],[Falsch])
https://github.com/Quaternijkon/notebook
https://raw.githubusercontent.com/Quaternijkon/notebook/main/content/数据结构与算法/.chapter-算法/数学/回文数.typ
typst
#import "../../../../lib.typ":* === #Title( title: [回文数], reflink: "https://leetcode.cn/problems/palindrome-number/description/", level: 1, )<回文数> #note( title: [ 回文数 ], description: [ 给你一个整数 x ,如果 x 是一个回文整数,返回 true ;否则,返回 false 。 回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。 例如,121 是回文,而 123 不是。 *你能不将整数转为字符串来解决这个问题吗?* ], examples: ([ 输入:x = 121 输出:true ],[ 输入:x = -121 输出:false 解释:从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。 ],[ 输入:x = 10 输出:false 解释:从右向左读, 为 01 。因此它不是一个回文数。 ] ), tips: [ $-2^31 <= x <= 2^31 - 1$ ], solutions: ( ( name:[组], text:[ 重新组成一个新数,判断是否和原数相等。 ],code:[ ```cpp class Solution { public: bool isPalindrome(int x) { if(x < 0) return false; int temp = x; long long res = 0; while(x){ res = res * 10 + x % 10; x /= 10; } return res == temp; } }; ``` ]),( name:[拆], text:[ 将数按头尾拆分,判断是否相等。 ],code:[ ```cpp class Solution { public: bool isPalindrome(int x) { if (x < 0) return false; int len = log10(x) + 1; int num = x; while (num) { int left = num / pow(10, len - 1); int right = num % 10; if (left != right) return false; num %= static_cast<int>(pow(10, len - 1)); num /= 10; len -= 2; } return true; } }; ``` ]),( name:[只反转一半], text:[ 为了避免数字反转可能导致的溢出问题,考虑只反转int数的一半。 对于数字 1221,如果执行 $1221 % 10$,我们将得到最后一位数字 1,要得到倒数第二位数字,我们可以先通过除以 10 把最后一位数字从 1221 中移除,$1221 / 10 = 122$,再求出上一步结果除以 10 的余数,$122 % 10 = 2$,就可以得到倒数第二位数字。如果我们把最后一位数字乘以 10,再加上倒数第二位数字,$1 * 10 + 2 = 12$,就得到了我们想要的反转后的数字。如果继续这个过程,我们将得到更多位数的反转数字。 现在的问题是,我们*如何知道反转数字的位数已经达到原始数字位数的一半*? 由于整个过程我们不断将原始数字除以 10,然后给反转后的数字乘上 10,所以,当原始数字小于或等于反转后的数字时,就意味着我们已经处理了一半位数的数字了。 ],code:[ ```cpp class Solution { public: bool isPalindrome(int x) { if (x < 0 || (x % 10 == 0 && x != 0)) { return false; } int revertedNumber = 0; while (x > revertedNumber) { revertedNumber = revertedNumber * 10 + x % 10; x /= 10; } // 当数字长度为奇数时,我们可以通过 revertedNumber/10 去除处于中位的数字。 // 例如,当输入为 12321 时,在 while 循环的末尾我们可以得到 x = 12,revertedNumber = 123, // 由于处于中位的数字不影响回文(它总是与自己相等),所以我们可以简单地将其去除。 return x == revertedNumber || x == revertedNumber / 10; } }; ``` ]) ), gain:none, )