Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

[task_01] Add solution #353

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f9df3a3
Create labb1.cpp
DemiurgeNC Dec 13, 2023
b3cc751
Create readme.md
DemiurgeNC Dec 13, 2023
dae5f23
Add files via upload
DemiurgeNC Dec 13, 2023
9c82bdb
Update readme.md
DemiurgeNC Dec 13, 2023
f843faa
Add files via upload
DemiurgeNC Dec 13, 2023
788a092
Update readme.md
DemiurgeNC Dec 13, 2023
c2cc6cf
Update readme.md
DemiurgeNC Dec 14, 2023
882d031
Update CMakeLists.txt
DemiurgeNC Dec 14, 2023
f041726
Update CMakeLists.txt
DemiurgeNC Dec 14, 2023
a67c385
Update labb1.cpp
DemiurgeNC Dec 14, 2023
6f6fee3
Update labb1.cpp
DemiurgeNC Dec 14, 2023
af68b45
Merge branch 'main' into task-01
DemiurgeNC Dec 14, 2023
d6dc3d9
Merge branch 'main' into task-01
Ghokury Dec 15, 2023
194b445
Update labb1.cpp
DemiurgeNC Dec 15, 2023
eb03716
Update labb1.cpp
DemiurgeNC Dec 15, 2023
7126b65
Update labb1.cpp
DemiurgeNC Dec 15, 2023
c634fe5
Update labb1.cpp
DemiurgeNC Dec 15, 2023
5e5942e
Merge branch 'main' into task-01
LapinVladimir Dec 18, 2023
6916807
Update labb1.cpp
DemiurgeNC Dec 18, 2023
405ee25
Update labb1.cpp
DemiurgeNC Dec 18, 2023
af91ee2
Merge branch 'main' into task-01
DemiurgeNC Dec 20, 2023
e367a83
Merge branch 'main' into task-01
DemiurgeNC Dec 21, 2023
3cdd76d
Merge branch 'main' into task-01
DemiurgeNC Dec 22, 2023
fc11dc8
Merge branch 'main' into task-01
DemiurgeNC Dec 23, 2023
9fc0473
Merge branch 'main' into task-01
VolkogonNikita Dec 24, 2023
bf4e20f
Merge branch 'main' into task-01
DemiurgeNC Dec 24, 2023
b27483c
Merge branch 'main' into task-01
DemiurgeNC Dec 25, 2023
6ddc3a0
Merge branch 'main' into task-01
DemiurgeNC Dec 26, 2023
2481db7
Merge branch 'main' into task-01
DemiurgeNC Dec 26, 2023
23b5965
Merge branch 'main' into task-01
DemiurgeNC Dec 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
| 10 | [Лапин Владимир](https://github.com/LapinVladimir) |[ii02310](trunk/ii02310) | ✅ | ✅ | ✅ | ✅ | ✅ | | | | 8|
| 11 | [Привезенцев Михаил](https://github.com/MishanyPrivezentsev)| | ❌ | ❌ | ❌ | ❌ | | | | | |
| 12 | [Ежевский Егор](https://github.com/pinkgrasss) |[ii02312](trunk/ii02312) | ✅ | ✅ | ✅ | ❌ | ✅ | | | | 7|
| 13 | Макаревич Кирилл | | | | ❌ | ❌ | | | | | |
| 13 | Макаревич Кирилл | | | | ❌ | ❌ | | | | | |
| 14 | [Макаревич Никита](https://github.com/sosiska52) |[ii02314](trunk/ii02314) | ✅ | ✅ | ✅ | ❌ | ✅ | | | | 7|
| 15 | Маслакова Ксения | | ❌ | ❌ | ❌ | ❌ | | | | | |
| 16 | [Медведь Павел](https://github.com/Dizzers) |[ii02316](trunk/ii02316) | ✅ | ✅ | ✅ | ✅ | ✅ | | | | 8|
Expand Down
Binary file added trunk/ii02313/task_01/doc/graphic.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
191 changes: 191 additions & 0 deletions trunk/ii02313/task_01/doc/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<p align="right"> Министерство образования Республики Беларусь</p>
<p align="right">Учреждение образования</p>
<p align="right">“Брестский Государственный технический университет”</p>
<p align="right">Кафедра ИИТ</p>
<br><br><br><br><br><br><br>
<p align="right">Лабораторная работа №1</p>
<p align="right">По дисциплине “Общая теория интеллектуальных систем”</p>
<p align="right">Тема: “Моделирования температуры объекта”</p>
<br><br><br><br><br>
<p align="right">Выполнил:</p>
<p align="right">Студент 2 курса</p>
<p align="right">Группы ИИ-23</p>
<p align="right">Макаревич К.А.</p>
<p align="right">Проверил:</p>
<p align="right">Иванюк Д. С.</p>
<br><br><br><br><br>
<p align="right">Брест 2023</p>

---

# Общее задание #
1. Написать отчет по выполненной лабораторной работе №1 в .md формате (readme.md) и с помощью запроса на внесение изменений (**pull request**) разместить его в следующем каталоге: **trunk\ii0xxyy\task_01\doc** (где **xx** - номер группы, **yy** - номер студента, например **ii02102**).
2. Исходный код написанной программы разместить в каталоге: **trunk\ii0xxyy\task_01\src**.

## Task 1. Modeling controlled object ##
Let's get some object to be controlled. We want to control its temperature, which can be described by this differential equation:

$$\Large\frac{dy(\tau)}{d\tau}=\frac{u(\tau)}{C}+\frac{Y_0-y(\tau)}{RC} $$ (1)

where $\tau$ – time; $y(\tau)$ – input temperature; $u(\tau)$ – input warm; $Y_0$ – room temperature; $C,RC$ – some constants.

After transformation we get these linear (2) and nonlinear (3) models:

$$\Large y_{\tau+1}=ay_{\tau}+bu_{\tau}$$ (2)
$$\Large y_{\tau+1}=ay_{\tau}-by_{\tau-1}^2+cu_{\tau}+d\sin(u_{\tau-1})$$ (3)

where $\tau$ – time discrete moments ($1,2,3{\dots}n$); $a,b,c,d$ – some constants.

Task is to write program (**C++**), which simulates this object temperature.

---

# Выполнение задания #

Код программы:
```C++
#include <iostream>
#include <cmath>

const float COEFFICIENT_A = 1;
const float COEFFICIENT_B = 0.02;
const float COEFFICIENT_C = 1;
const float COEFFICIENT_D = 1;

// Calculate the temperature using a linear model
void linearmod(float y, float j, int tend) {
for (int t = 1; t <= tend; ++t) {
float y_sld = COEFFICIENT_A * y + COEFFICIENT_B * j;
y = y_sld;
std::cout << y_sld << "\n";
}
}

// Calculate the temperature using a nonlinear model
void nonlinearmod(float y_pred, float y, float j, int tend) {
for (int t = 1; t <= tend; ++t) {
float y_sld = COEFFICIENT_A * y - COEFFICIENT_B * pow(y_pred, 2) + COEFFICIENT_C * j + COEFFICIENT_D * sin(j);
y_pred = y;
y = y_sld;
std::cout << y_sld << "\n";
}
}

// Ending alert output
void ans() {
std::cout << "\nModeling ended.\n";
}

int main() {
float initialTemperature;
float warm;
int Tend;

//Setting starting temp
std::cout << "Enter starting temperature: ";
std::cin >> initialTemperature;

//Checking if it's acceptable
while (initialTemperature < 0 || initialTemperature > 100) {
std::cout << "Starting temperature must be from 0 to 100. Please try again: ";
std::cin >> initialTemperature;
}

//Setting warming
std::cout << "Enter warming: ";
std::cin >> warm;

//Setting end time
std::cout << "Enter end time: ";
std::cin >> Tend;

//Output of linear modeling
std::cout << "\nResults of linear modeling:\n";
linearmod(initialTemperature, warm, Tend);

//Output of linear modeling
std::cout << "\nResult of nonlinear modeling:\n";
nonlinearmod(0, initialTemperature, warm, Tend);

// Finishing task
ans();

return 0;
}
```вывод
Enter starting temperature: 33
Enter warming: 1
Enter end time: 33

Results of linear modeling:
33.02
33.04
33.06
33.08
33.1
33.12
33.14
33.16
33.18
33.2
33.22
33.24
33.26
33.28
33.3
33.32
33.34
33.36
33.38
33.4
33.42
33.44
33.46
33.48
33.5
33.52
33.54
33.56
33.58
33.6
33.62
33.64
33.66

Result of nonlinear modeling:
34.8415
14.9029
-7.53415
-10.1346
-9.42843
-9.64117
-9.57761
-9.59518
-9.58832
-9.5882
-9.58545
-9.58265
-9.57879
-9.57387
-9.56746
-9.55917
-9.54843
-9.53451
-9.51649
-9.49315
-9.46295
-9.42388
-9.37336
-9.30808
-9.11514
-8.97524
-8.79548
-8.56511
-8.27085
-7.8966
-7.42327
-6.82892

Modeling ended.
```
![График:](graphic.jpg)
6 changes: 6 additions & 0 deletions trunk/ii02313/task_01/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.27.8)
project("labb1")

set(CMAKE_CXX_STANDARD 17)

add_executable(io_17 labb1_1.cpp)
68 changes: 68 additions & 0 deletions trunk/ii02313/task_01/src/labb1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include <iostream>
#include <cmath>

const float COEFFICIENT_A = 1;
const float COEFFICIENT_B = 0.02;
const float COEFFICIENT_C = 1;
const float COEFFICIENT_D = 1;

// Calculate the temperature using a linear model
void linearmod(float y, float j, int tend) {
for (int t = 1; t <= tend; ++t) {
float y_sld = COEFFICIENT_A * y + COEFFICIENT_B * j;
y = y_sld;
std::cout << y_sld << "\n";
}
}

// Calculate the temperature using a nonlinear model
void nonlinearmod(float y_pred, float y, float j, int tend) {
for (int t = 1; t <= tend; ++t) {
float y_sld = COEFFICIENT_A * y - COEFFICIENT_B * pow(y_pred, 2) + COEFFICIENT_C * j + COEFFICIENT_D * sin(j);
y_pred = y;
y = y_sld;
std::cout << y_sld << "\n";
}
}

// Ending alert output
void ans() {
std::cout << "\nModeling ended.\n";
}

int main() {
float initialTemperature;
float warm;
int Tend;

//Setting starting temp
std::cout << "Enter starting temperature: ";
std::cin >> initialTemperature;

//Checking if it's acceptable
while (initialTemperature < 0 || initialTemperature > 100) {
std::cout << "Starting temperature must be from 0 to 100. Please try again: ";
std::cin >> initialTemperature;
}

//Setting warming
std::cout << "Enter warming: ";
std::cin >> warm;

//Setting end time
std::cout << "Enter end time: ";
std::cin >> Tend;

//Output of linear modeling
std::cout << "\nResults of linear modeling:\n";
linearmod(initialTemperature, warm, Tend);

//Output of linear modeling
std::cout << "\nResult of nonlinear modeling:\n";
nonlinearmod(0, initialTemperature, warm, Tend);

// Finishing task
ans();

return 0;
}
Loading