...
 
Commits (2)
......@@ -31,7 +31,8 @@ SOURCES += main.cpp\
glpk.cpp \
simulationresultwidget.cpp \
householdseditorwidget.cpp \
configurationwidget.cpp
configurationwidget.cpp \
progressbar.cpp
HEADERS += mainwindow.h \
dataeditorwidget.h \
......@@ -39,13 +40,15 @@ HEADERS += mainwindow.h \
glpk.h \
simulationresultwidget.h \
householdseditorwidget.h \
configurationwidget.h
configurationwidget.h \
progressbar.h
FORMS += mainwindow.ui \
dataeditorwidget.ui \
simulationresultwidget.ui \
householdseditorwidget.ui \
configurationwidget.ui
configurationwidget.ui \
progressbar.ui
RESOURCES += \
resources.qrc
......
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>340</width>
<height>237</height>
<width>428</width>
<height>258</height>
</rect>
</property>
<property name="windowTitle">
......@@ -20,10 +20,10 @@
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>171</x>
<y>196</y>
<width>158</width>
<height>25</height>
<x>220</x>
<y>220</y>
<width>195</width>
<height>30</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
......@@ -49,12 +49,12 @@
<x>20</x>
<y>10</y>
<width>281</width>
<height>24</height>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<family>Microsoft Sans Serif</family>
<family>Nirmala UI</family>
<pointsize>14</pointsize>
</font>
</property>
......@@ -66,8 +66,8 @@
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>171</width>
<y>62</y>
<width>211</width>
<height>16</height>
</rect>
</property>
......@@ -78,8 +78,8 @@
<widget class="QSpinBox" name="spinViviendas">
<property name="geometry">
<rect>
<x>200</x>
<y>48</y>
<x>240</x>
<y>60</y>
<width>42</width>
<height>22</height>
</rect>
......@@ -92,8 +92,8 @@
<property name="geometry">
<rect>
<x>20</x>
<y>80</y>
<width>131</width>
<y>92</y>
<width>161</width>
<height>16</height>
</rect>
</property>
......@@ -105,8 +105,8 @@
<property name="geometry">
<rect>
<x>200</x>
<y>78</y>
<width>111</width>
<y>90</y>
<width>141</width>
<height>22</height>
</rect>
</property>
......@@ -128,13 +128,13 @@
<property name="geometry">
<rect>
<x>20</x>
<y>114</y>
<y>126</y>
<width>271</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Cargar al iniciar el ultimo sorteo creado</string>
<string>Cargar al iniciar el último sorteo creado</string>
</property>
<property name="iconSize">
<size>
......@@ -147,13 +147,13 @@
<property name="geometry">
<rect>
<x>20</x>
<y>137</y>
<y>149</y>
<width>271</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Guardar automaticamente reportes en:</string>
<string>Guardar automáticamente reportes en:</string>
</property>
<property name="iconSize">
<size>
......@@ -166,7 +166,7 @@
<property name="geometry">
<rect>
<x>36</x>
<y>160</y>
<y>172</y>
<width>211</width>
<height>20</height>
</rect>
......@@ -176,7 +176,7 @@
<property name="geometry">
<rect>
<x>253</x>
<y>158</y>
<y>170</y>
<width>75</width>
<height>23</height>
</rect>
......
......@@ -11,9 +11,12 @@
#include <QDateTime>
#include <QFuture>
#include <QtConcurrent/QtConcurrent>
#include <QProgressBar>
#include <QProgressDialog>
#include "mainwindow.h"
#include "glpk.h"
// Constructor
DataEditorWidget::DataEditorWidget(QWidget *parent) :
QWidget(parent),
......@@ -23,6 +26,7 @@ DataEditorWidget::DataEditorWidget(QWidget *parent) :
ui->setupUi(this);
this->simulationResult = new SimulationResultWidget();
this->progressbar = new ProgressBar();
ui->tableView->verticalHeader()->setVisible(false);
......@@ -58,11 +62,15 @@ void DataEditorWidget::on_btnSimular_clicked()
qInfo() << "Inicio de ejecucion del Proyecto=" + this->simulacion->getNombre();
// show Ejecutando..
// Ejecuta los datos en GLPK
glpk.ejecutar(process);
bool cancelled = glpk.ejecutar(process, this);
// Abre ventana de resultados de la simulacion
this->simulationResult->abrirDialog(this->simulacion);
if (!cancelled) {
this->simulationResult->abrirDialog(this->simulacion);
}
if (settings.value("GUARDAR_AUTOMATICAMENTE_REPORTE").toBool()) {
QString dir = settings.value("GUARDAR_REPORTE_DIR").toString();
......@@ -82,8 +90,11 @@ void DataEditorWidget::on_btnSimular_clicked()
delete process;
}else {
qWarning() << "Datos invalidos para correr el proyecto: " + result;
qWarning() << "Datos incorrectos el proyecto: " + result;
QMessageBox msgBox;
msgBox.setWindowTitle(" Datos incorrectos el proyecto: ");
QIcon ico = QIcon(":/recursos/img/vivienda.ico");
msgBox.setWindowIcon(ico);
msgBox.setText(result);
msgBox.setIcon(QMessageBox::Critical);
msgBox.setButtonText(QMessageBox::Ok, tr("Aceptar"));
......
......@@ -4,6 +4,7 @@
#include <QWidget>
#include <QStandardItemModel>
#include <QSettings>
#include "progressbar.h"
#include "simulation.h"
#include "simulationresultwidget.h"
......@@ -20,6 +21,7 @@ private:
QStandardItemModel *tablaModelFamily = NULL;
QSettings settings;
Simulation *simulacion = NULL;
ProgressBar *progressbar;
SimulationResultWidget *simulationResult = NULL;
bool huboCambios;
void simular();
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>685</width>
<height>323</height>
<width>727</width>
<height>322</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -35,6 +35,78 @@
<property name="bottomMargin">
<number>4</number>
</property>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout">
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTableView" name="tableViewFamily">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustIgnored</enum>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerItem</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QTableView" name="tableView">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="midLineWidth">
<number>0</number>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked</set>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerItem</enum>
</property>
<property name="cornerButtonEnabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
......@@ -55,10 +127,10 @@
<widget class="QPushButton" name="btnSimular">
<property name="geometry">
<rect>
<x>570</x>
<y>22</y>
<width>81</width>
<height>31</height>
<x>610</x>
<y>20</y>
<width>51</width>
<height>41</height>
</rect>
</property>
<property name="font">
......@@ -66,18 +138,24 @@
<pointsize>10</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Asignar</string>
<string/>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/recursos/img/play.png</normaloff>:/recursos/img/play.png</iconset>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
<widget class="QLineEdit" name="txtNombre">
<property name="geometry">
<rect>
<x>106</x>
<x>130</x>
<y>29</y>
<width>171</width>
<height>20</height>
......@@ -89,7 +167,7 @@
<rect>
<x>10</x>
<y>30</y>
<width>91</width>
<width>111</width>
<height>16</height>
</rect>
</property>
......@@ -100,7 +178,7 @@
<widget class="QSpinBox" name="spinViviendas">
<property name="geometry">
<rect>
<x>410</x>
<x>460</x>
<y>28</y>
<width>42</width>
<height>22</height>
......@@ -113,9 +191,9 @@
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>290</x>
<x>320</x>
<y>30</y>
<width>111</width>
<width>141</width>
<height>16</height>
</rect>
</property>
......@@ -126,9 +204,9 @@
<widget class="QPushButton" name="btnAplicar">
<property name="geometry">
<rect>
<x>470</x>
<x>510</x>
<y>27</y>
<width>75</width>
<width>61</width>
<height>23</height>
</rect>
</property>
......@@ -138,78 +216,6 @@
</widget>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout">
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTableView" name="tableViewFamily">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustIgnored</enum>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerItem</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QTableView" name="tableView">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="midLineWidth">
<number>0</number>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked</set>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerItem</enum>
</property>
<property name="cornerButtonEnabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
......
data;
set C := c2 c0 c1;
set C := c1 c4 c3 c0 c2;
set V := v0 v1 v2;
set V := v0 v1 v2 v3 v4;
param p : v0 v1 v2 :=
c2 3 2 1
c0 1 2 3
c1 2 3 1
param p : v0 v1 v2 v3 v4 :=
c1 5 4 3 1 2
c4 5 3 2 1 3
c3 5 4 3 2 1
c0 5 1 4 1 3
c2 5 4 3 1 2
;
end;= v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 v17 v18 v19 v20 v21 v22 v23 v24 v25 v26 v27 v28 v29 v30 v31 v32 v33 v34 v35;
param p : v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 v17 v18 v19 v20 v21 v22 v23 v24 v25 v26 v27 v28 v29 v30 v31 v32 v33 v34 v35 :=
c12 6 5 33 31 34 32 36 35 4 27 25 28 26 30 29 3 21 19 22 20 24 23 2 15 13 16 14 18 17 1 11 9 12 10 8 7
c1 36 5 35 10 17 11 22 14 1 34 6 18 12 23 15 2 33 7 19 13 24 16 3 32 8 20 27 25 29 4 31 9 21 28 26 30
c9 11 12 35 36 33 34 27 28 4 31 32 29 30 13 14 3 23 26 24 25 9 10 2 16 18 20 22 7 8 1 15 17 19 21 5 6
c24 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 4 14 16 13 21 12 11 6 9 17 3 18 2 10 7 8 15 1 19 5 20
c0 26 25 34 33 36 35 28 27 4 30 29 32 31 14 13 3 20 19 24 23 10 9 2 16 15 22 21 8 7 1 12 11 18 17 6 5
c27 33 36 35 34 31 32 29 30 28 24 25 26 27 22 23 17 21 18 19 20 15 16 6 12 13 14 11 9 10 2 4 7 5 8 1 3
c25 36 16 20 21 26 27 34 35 10 18 19 24 25 32 33 3 13 17 22 23 30 31 2 8 9 14 15 28 29 1 6 7 11 12 4 5
c31 22 5 34 33 36 35 24 23 3 21 20 32 31 19 18 2 17 16 30 29 9 8 1 15 14 26 25 7 6 4 13 12 28 27 11 10
c29 20 19 31 32 35 36 21 22 13 27 28 33 34 11 12 14 23 24 29 30 3 4 15 5 6 25 26 1 2 16 9 10 17 18 7 8
c15 28 27 34 33 36 35 24 23 20 25 26 32 31 17 16 13 19 18 29 30 8 7 11 10 9 21 22 2 1 12 6 5 14 15 3 4
c18 36 23 29 32 34 35 28 27 4 20 31 25 33 26 22 3 14 21 24 30 18 15 2 8 17 16 19 13 9 1 7 11 10 12 6 5
c28 30 21 35 36 32 31 17 18 12 34 33 29 28 14 13 7 23 22 27 26 11 10 4 20 19 25 24 5 6 3 9 8 16 15 1 2
c32 19 15 33 36 34 35 14 13 12 29 32 30 31 11 9 10 25 27 26 28 8 7 5 17 23 22 24 4 1 6 16 18 20 21 3 2
c13 14 13 26 28 35 36 22 21 12 25 27 33 34 20 19 11 23 24 31 32 17 18 8 9 10 29 30 6 7 3 4 5 15 16 1 2
c23 36 1 22 23 18 19 20 21 5 24 25 26 27 28 29 3 30 31 32 33 34 35 4 17 16 12 13 14 15 2 9 11 6 10 7 8
c33 36 35 34 33 32 31 30 29 4 28 27 26 25 12 11 2 24 23 22 21 6 10 1 17 18 19 20 5 8 3 13 14 15 16 7 9
c26 36 18 28 35 30 34 31 29 1 22 33 23 32 27 19 7 20 24 21 25 26 14 2 12 16 13 17 15 9 8 3 10 4 11 6 5
c3 36 27 33 32 35 34 22 21 20 29 28 31 30 19 18 11 23 24 26 25 15 14 6 9 10 17 16 5 1 4 7 8 13 12 3 2
c20 36 20 30 31 34 35 17 8 18 26 27 32 33 16 6 9 13 15 28 29 14 1 10 4 11 22 23 2 3 21 12 19 24 25 7 5
c17 20 8 35 36 33 34 27 28 6 30 29 31 32 26 25 4 23 24 21 22 10 11 3 17 16 18 19 5 9 2 14 15 12 13 1 7
c8 36 35 31 32 33 34 12 13 26 27 28 29 30 10 11 1 22 23 24 25 6 7 2 18 19 20 21 4 5 3 14 15 16 17 8 9
c19 18 36 34 35 33 32 31 30 23 27 26 29 28 25 24 17 20 19 22 21 12 13 14 11 10 16 15 4 3 7 6 5 9 8 1 2
c22 11 5 16 10 21 26 31 36 4 15 9 20 25 30 35 3 14 8 19 24 29 34 1 12 6 17 22 27 32 2 13 7 18 23 28 33
c34 36 21 30 31 34 35 22 23 4 19 20 32 33 11 12 3 17 18 28 29 9 10 1 13 14 26 27 5 7 2 15 16 24 25 6 8
c30 36 22 23 24 33 32 15 14 10 21 19 31 34 9 13 1 17 8 18 35 2 3 4 20 5 28 27 6 7 16 25 26 29 30 11 12
c7 36 14 35 34 33 32 12 13 4 31 30 29 28 11 7 1 26 25 23 24 8 5 2 22 20 16 18 9 6 3 21 19 15 17 10 27
c6 36 8 31 32 33 35 15 14 3 28 29 30 34 13 12 2 24 25 26 27 7 5 1 23 22 17 19 6 4 9 21 20 16 18 11 10
c11 28 2 34 36 33 35 17 19 1 29 32 30 31 16 18 20 14 26 12 25 8 9 21 11 27 10 24 3 7 22 6 15 13 23 4 5
c5 36 21 35 33 34 32 23 22 3 30 31 29 28 10 9 2 24 25 27 26 8 6 1 18 17 20 19 7 5 4 14 13 16 15 12 11
c4 36 19 33 32 34 35 22 23 8 29 28 30 31 20 21 5 25 24 27 26 17 18 4 15 16 13 14 6 7 3 10 9 11 12 1 2
c2 36 28 24 21 22 23 35 17 18 33 34 16 15 32 14 4 25 12 31 13 30 6 3 29 10 20 11 26 5 1 19 7 27 9 8 2
c21 10 7 36 35 34 33 19 20 4 32 31 30 29 14 13 3 28 27 26 25 12 11 2 24 23 22 21 9 8 1 18 17 16 15 6 5
c14 36 2 32 33 34 35 24 25 1 28 29 30 31 12 13 3 20 21 26 27 10 11 4 18 19 22 23 8 9 5 14 15 16 17 6 7
c35 36 23 33 32 34 35 31 30 10 26 27 29 28 25 24 7 22 21 20 19 8 9 2 16 15 18 17 5 6 1 11 12 13 14 3 4
c10 12 11 27 32 35 36 15 16 4 26 31 34 33 13 14 3 25 30 29 28 9 10 2 22 21 23 24 7 8 1 18 17 19 20 5 6
c16 2 6 31 32 33 34 35 36 5 25 26 27 28 29 30 4 15 16 21 22 23 24 3 13 14 17 18 19 20 1 8 7 9 10 11 12
;
end;
\ No newline at end of file
data;
set C := c2 c0 c1;
set C := c1 c4 c3 c0 c2;
set V := v0 v1 v2;
set V := v0 v1 v2 v3 v4;
param S := 2;
param S := 5;
param p : v0 v1 v2 :=
c2 3 2 1
c0 1 2 3
c1 2 3 1
param p : v0 v1 v2 v3 v4 :=
c1 5 4 3 1 2
c4 5 3 2 1 3
c3 5 4 3 2 1
c0 5 1 4 1 3
c2 5 4 3 1 2
;
end;4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 v17 v18 v19 v20 v21 v22 v23 v24 v25 v26 v27 v28 v29 v30 v31 v32 v33 v34 v35;
param S := 31;
param p : v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 v17 v18 v19 v20 v21 v22 v23 v24 v25 v26 v27 v28 v29 v30 v31 v32 v33 v34 v35 :=
c12 6 5 33 31 34 32 36 35 4 27 25 28 26 30 29 3 21 19 22 20 24 23 2 15 13 16 14 18 17 1 11 9 12 10 8 7
c1 36 5 35 10 17 11 22 14 1 34 6 18 12 23 15 2 33 7 19 13 24 16 3 32 8 20 27 25 29 4 31 9 21 28 26 30
c9 11 12 35 36 33 34 27 28 4 31 32 29 30 13 14 3 23 26 24 25 9 10 2 16 18 20 22 7 8 1 15 17 19 21 5 6
c24 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 4 14 16 13 21 12 11 6 9 17 3 18 2 10 7 8 15 1 19 5 20
c0 26 25 34 33 36 35 28 27 4 30 29 32 31 14 13 3 20 19 24 23 10 9 2 16 15 22 21 8 7 1 12 11 18 17 6 5
c27 33 36 35 34 31 32 29 30 28 24 25 26 27 22 23 17 21 18 19 20 15 16 6 12 13 14 11 9 10 2 4 7 5 8 1 3
c25 36 16 20 21 26 27 34 35 10 18 19 24 25 32 33 3 13 17 22 23 30 31 2 8 9 14 15 28 29 1 6 7 11 12 4 5
c31 22 5 34 33 36 35 24 23 3 21 20 32 31 19 18 2 17 16 30 29 9 8 1 15 14 26 25 7 6 4 13 12 28 27 11 10
c29 20 19 31 32 35 36 21 22 13 27 28 33 34 11 12 14 23 24 29 30 3 4 15 5 6 25 26 1 2 16 9 10 17 18 7 8
c15 28 27 34 33 36 35 24 23 20 25 26 32 31 17 16 13 19 18 29 30 8 7 11 10 9 21 22 2 1 12 6 5 14 15 3 4
c18 36 23 29 32 34 35 28 27 4 20 31 25 33 26 22 3 14 21 24 30 18 15 2 8 17 16 19 13 9 1 7 11 10 12 6 5
c28 30 21 35 36 32 31 17 18 12 34 33 29 28 14 13 7 23 22 27 26 11 10 4 20 19 25 24 5 6 3 9 8 16 15 1 2
c32 19 15 33 36 34 35 14 13 12 29 32 30 31 11 9 10 25 27 26 28 8 7 5 17 23 22 24 4 1 6 16 18 20 21 3 2
c13 14 13 26 28 35 36 22 21 12 25 27 33 34 20 19 11 23 24 31 32 17 18 8 9 10 29 30 6 7 3 4 5 15 16 1 2
c23 36 1 22 23 18 19 20 21 5 24 25 26 27 28 29 3 30 31 32 33 34 35 4 17 16 12 13 14 15 2 9 11 6 10 7 8
c33 36 35 34 33 32 31 30 29 4 28 27 26 25 12 11 2 24 23 22 21 6 10 1 17 18 19 20 5 8 3 13 14 15 16 7 9
c26 36 18 28 35 30 34 31 29 1 22 33 23 32 27 19 7 20 24 21 25 26 14 2 12 16 13 17 15 9 8 3 10 4 11 6 5
c3 36 27 33 32 35 34 22 21 20 29 28 31 30 19 18 11 23 24 26 25 15 14 6 9 10 17 16 5 1 4 7 8 13 12 3 2
c20 36 20 30 31 34 35 17 8 18 26 27 32 33 16 6 9 13 15 28 29 14 1 10 4 11 22 23 2 3 21 12 19 24 25 7 5
c17 20 8 35 36 33 34 27 28 6 30 29 31 32 26 25 4 23 24 21 22 10 11 3 17 16 18 19 5 9 2 14 15 12 13 1 7
c8 36 35 31 32 33 34 12 13 26 27 28 29 30 10 11 1 22 23 24 25 6 7 2 18 19 20 21 4 5 3 14 15 16 17 8 9
c19 18 36 34 35 33 32 31 30 23 27 26 29 28 25 24 17 20 19 22 21 12 13 14 11 10 16 15 4 3 7 6 5 9 8 1 2
c22 11 5 16 10 21 26 31 36 4 15 9 20 25 30 35 3 14 8 19 24 29 34 1 12 6 17 22 27 32 2 13 7 18 23 28 33
c34 36 21 30 31 34 35 22 23 4 19 20 32 33 11 12 3 17 18 28 29 9 10 1 13 14 26 27 5 7 2 15 16 24 25 6 8
c30 36 22 23 24 33 32 15 14 10 21 19 31 34 9 13 1 17 8 18 35 2 3 4 20 5 28 27 6 7 16 25 26 29 30 11 12
c7 36 14 35 34 33 32 12 13 4 31 30 29 28 11 7 1 26 25 23 24 8 5 2 22 20 16 18 9 6 3 21 19 15 17 10 27
c6 36 8 31 32 33 35 15 14 3 28 29 30 34 13 12 2 24 25 26 27 7 5 1 23 22 17 19 6 4 9 21 20 16 18 11 10
c11 28 2 34 36 33 35 17 19 1 29 32 30 31 16 18 20 14 26 12 25 8 9 21 11 27 10 24 3 7 22 6 15 13 23 4 5
c5 36 21 35 33 34 32 23 22 3 30 31 29 28 10 9 2 24 25 27 26 8 6 1 18 17 20 19 7 5 4 14 13 16 15 12 11
c4 36 19 33 32 34 35 22 23 8 29 28 30 31 20 21 5 25 24 27 26 17 18 4 15 16 13 14 6 7 3 10 9 11 12 1 2
c2 36 28 24 21 22 23 35 17 18 33 34 16 15 32 14 4 25 12 31 13 30 6 3 29 10 20 11 26 5 1 19 7 27 9 8 2
c21 10 7 36 35 34 33 19 20 4 32 31 30 29 14 13 3 28 27 26 25 12 11 2 24 23 22 21 9 8 1 18 17 16 15 6 5
c14 36 2 32 33 34 35 24 25 1 28 29 30 31 12 13 3 20 21 26 27 10 11 4 18 19 22 23 8 9 5 14 15 16 17 6 7
c35 36 23 33 32 34 35 31 30 10 26 27 29 28 25 24 7 22 21 20 19 8 9 2 16 15 18 17 5 6 1 11 12 13 14 3 4
c10 12 11 27 32 35 36 15 16 4 26 31 34 33 13 14 3 25 30 29 28 9 10 2 22 21 23 24 7 8 1 18 17 19 20 5 6
c16 2 6 31 32 33 34 35 36 5 25 26 27 28 29 30 4 15 16 21 22 23 24 3 13 14 17 18 19 20 1 8 7 9 10 11 12
;
end;
\ No newline at end of file
......@@ -2,8 +2,8 @@ Reading model section from GLPK/Modelos/MTAV.mod...
GLPK/Modelos/MTAV.mod:29: warning: unexpected end of file; missing end statement inserted
29 lines were read
Reading data section from GLPK/Datos/MTAV_pref.dat...
GLPK/Datos/MTAV_pref.dat:13: warning: final NL missing before end of file
13 lines were read
GLPK/Datos/MTAV_pref.dat:15: warning: some text detected beyond end statement; text ignored
15 lines were read
Generating resultado...
Generating z_menorIgual...
Generating unicaAsignacionCoperativista_mayorIgual...
......@@ -11,19 +11,19 @@ Generating unicaAsignacionCoperativista_menorIgual...
Generating unicaAsignacionCasa_mayorIgual...
Generating unicaAsignacionCasa_menorIgual...
Model has been successfully generated
lpx_simplex: original LP has 16 rows, 10 columns, 49 non-zeros
lpx_simplex: presolved LP has 15 rows, 10 columns, 48 non-zeros
lpx_adv_basis: size of triangular part = 15
* 8: objval = 2.000000000e+000 infeas = 0.000000000e+000 (0)
* 15: objval = 1.500000000e+000 infeas = 1.110223025e-016 (0)
lpx_simplex: original LP has 26 rows, 26 columns, 131 non-zeros
lpx_simplex: presolved LP has 25 rows, 26 columns, 130 non-zeros
lpx_adv_basis: size of triangular part = 25
0: objval = 0.000000000e+000 infeas = 1.000000000e+000 (0)
18: objval = 3.064516129e+000 infeas = 4.440892099e-017 (0)
* 18: objval = 3.064516129e+000 infeas = 4.440892099e-016 (0)
OPTIMAL SOLUTION FOUND
Integer optimization begins...
Objective function is integral
+ 15: mip = not found yet >= -inf (1; 0)
+ 20: mip = 3.000000000e+000 >= 2.000000000e+000 33.3% (3; 0)
+ 24: mip = 2.000000000e+000 >= 2.000000000e+000 0.0% (4; 1)
+ 24: mip = 2.000000000e+000 >= tree is empty 0.0% (0; 9)
+ 28: mip = not found yet >= -inf (1; 0)
+ 55: mip = 5.000000000e+000 >= 3.000000000e+000 40.0% (4; 0)
+ 252: mip = 5.000000000e+000 >= tree is empty 0.0% (0; 47)
INTEGER OPTIMAL SOLUTION FOUND
Time used: 0.0 secs
Memory used: 0.2M (178873 bytes)
Memory used: 0.2M (186337 bytes)
lpx_print_mip: writing MIP problem solution to `GLPK/Soluciones/MTAV_pref.sol'...
Problem: MTAV
Rows: 16
Columns: 10 (10 integer, 9 binary)
Non-zeros: 49
Rows: 26
Columns: 26 (26 integer, 25 binary)
Non-zeros: 131
Status: INTEGER OPTIMAL
Objective: resultado = 2 (MINimum) 1.5 (LP)
Objective: resultado = 5 (MINimum) 2.25 (LP)
No. Row name Activity Lower bound Upper bound
------ ------------ ------------- ------------- -------------
1 resultado 2
2 z_menorIgual[c2]
0 -0
3 z_menorIgual[c0]
1 -0
4 z_menorIgual[c1]
1 resultado 5
2 z_menorIgual[c1]
1 -0
5 unicaAsignacionCoperativista_mayorIgual[c2]
3 z_menorIgual[c4]
4 -0
4 z_menorIgual[c3]
0 -0
5 z_menorIgual[c0]
2 -0
6 z_menorIgual[c2]
2 -0
7 unicaAsignacionCoperativista_mayorIgual[c1]
1 1
6 unicaAsignacionCoperativista_mayorIgual[c0]
8 unicaAsignacionCoperativista_mayorIgual[c4]
1 1
7 unicaAsignacionCoperativista_mayorIgual[c1]
9 unicaAsignacionCoperativista_mayorIgual[c3]
1 1
10 unicaAsignacionCoperativista_mayorIgual[c0]
1 1
11 unicaAsignacionCoperativista_mayorIgual[c2]
1 1
8 unicaAsignacionCoperativista_menorIgual[c2]
12 unicaAsignacionCoperativista_menorIgual[c1]
1 1
9 unicaAsignacionCoperativista_menorIgual[c0]
13 unicaAsignacionCoperativista_menorIgual[c4]
1 1
10 unicaAsignacionCoperativista_menorIgual[c1]
14 unicaAsignacionCoperativista_menorIgual[c3]
1 1
11 unicaAsignacionCasa_mayorIgual[v0]
15 unicaAsignacionCoperativista_menorIgual[c0]
1 1
16 unicaAsignacionCoperativista_menorIgual[c2]
1 1
17 unicaAsignacionCasa_mayorIgual[v0]
1 1
18 unicaAsignacionCasa_mayorIgual[v1]
1 1
12 unicaAsignacionCasa_mayorIgual[v1]
19 unicaAsignacionCasa_mayorIgual[v2]
1 1
13 unicaAsignacionCasa_mayorIgual[v2]
20 unicaAsignacionCasa_mayorIgual[v3]
1 1
14 unicaAsignacionCasa_menorIgual[v0]
21 unicaAsignacionCasa_mayorIgual[v4]
1 1
22 unicaAsignacionCasa_menorIgual[v0]
1 1
23 unicaAsignacionCasa_menorIgual[v1]
1 1
24 unicaAsignacionCasa_menorIgual[v2]
1 1
15 unicaAsignacionCasa_menorIgual[v1]
25 unicaAsignacionCasa_menorIgual[v3]
1 1
16 unicaAsignacionCasa_menorIgual[v2]
26 unicaAsignacionCasa_menorIgual[v4]
1 1
No. Column name Activity Lower bound Upper bound
------ ------------ ------------- ------------- -------------
1 x[c2,v0] * 0 0 1
2 x[c2,v1] * 1 0 1
3 x[c2,v2] * 0 0 1
4 x[c0,v0] * 1 0 1
5 x[c0,v1] * 0 0 1
6 x[c0,v2] * 0 0 1
7 x[c1,v0] * 0 0 1
8 x[c1,v1] * 0 0 1
9 x[c1,v2] * 1 0 1
10 z * 2
1 x[c1,v0] * 0 0 1
2 x[c1,v1] * 1 0 1
3 x[c1,v2] * 0 0 1
4 x[c1,v3] * 0 0 1
5 x[c1,v4] * 0 0 1
6 x[c4,v0] * 0 0 1
7 x[c4,v1] * 0 0 1
8 x[c4,v2] * 0 0 1
9 x[c4,v3] * 1 0 1
10 x[c4,v4] * 0 0 1
11 x[c3,v0] * 1 0 1
12 x[c3,v1] * 0 0 1
13 x[c3,v2] * 0 0 1
14 x[c3,v3] * 0 0 1
15 x[c3,v4] * 0 0 1
16 x[c0,v0] * 0 0 1
17 x[c0,v1] * 0 0 1
18 x[c0,v2] * 0 0 1
19 x[c0,v3] * 0 0 1
20 x[c0,v4] * 1 0 1
21 x[c2,v0] * 0 0 1
22 x[c2,v1] * 0 0 1
23 x[c2,v2] * 1 0 1
24 x[c2,v3] * 0 0 1
25 x[c2,v4] * 0 0 1
26 z * 5
End of output
Problem: MTAV_empate
Rows: 16
Columns: 9 (9 integer, 9 binary)
Non-zeros: 54
Rows: 26
Columns: 25 (25 integer, 25 binary)
Non-zeros: 150
Status: INTEGER OPTIMAL
Objective: s = 4 (MINimum) 4 (LP)
Objective: s = 10 (MINimum) 10 (LP)
No. Row name Activity Lower bound Upper bound
------ ------------ ------------- ------------- -------------
1 s 4
2 unicaAsignacionCoperativista_mayorIgual[c2]
1 s 10
2 unicaAsignacionCoperativista_mayorIgual[c1]
1 1
3 unicaAsignacionCoperativista_mayorIgual[c0]
3 unicaAsignacionCoperativista_mayorIgual[c4]
1 1
4 unicaAsignacionCoperativista_mayorIgual[c1]
4 unicaAsignacionCoperativista_mayorIgual[c3]
1 1
5 unicaAsignacionCoperativista_menorIgual[c2]
5 unicaAsignacionCoperativista_mayorIgual[c0]
1 1
6 unicaAsignacionCoperativista_mayorIgual[c2]
1 1
7 unicaAsignacionCoperativista_menorIgual[c1]
1 1
6 unicaAsignacionCoperativista_menorIgual[c0]
8 unicaAsignacionCoperativista_menorIgual[c4]
1 1
7 unicaAsignacionCoperativista_menorIgual[c1]
9 unicaAsignacionCoperativista_menorIgual[c3]
1 1
10 unicaAsignacionCoperativista_menorIgual[c0]
1 1
8 unicaAsignacionCasa_mayorIgual[v0]
11 unicaAsignacionCoperativista_menorIgual[c2]
1 1
12 unicaAsignacionCasa_mayorIgual[v0]
1 1
13 unicaAsignacionCasa_mayorIgual[v1]
1 1
14 unicaAsignacionCasa_mayorIgual[v2]
1 1
9 unicaAsignacionCasa_mayorIgual[v1]
15 unicaAsignacionCasa_mayorIgual[v3]
1 1
10 unicaAsignacionCasa_mayorIgual[v2]
16 unicaAsignacionCasa_mayorIgual[v4]
1 1
11 unicaAsignacionCasa_menorIgual[v0]
17 unicaAsignacionCasa_menorIgual[v0]
1 1
18 unicaAsignacionCasa_menorIgual[v1]
1 1
19 unicaAsignacionCasa_menorIgual[v2]
1 1
12 unicaAsignacionCasa_menorIgual[v1]
20 unicaAsignacionCasa_menorIgual[v3]
1 1
13 unicaAsignacionCasa_menorIgual[v2]
21 unicaAsignacionCasa_menorIgual[v4]
1 1
14 z_menorIgual[c2]
2 2
15 z_menorIgual[c0]
1 2
16 z_menorIgual[c1]
1 2
22 z_menorIgual[c1]
5 5
23 z_menorIgual[c4]
2 5
24 z_menorIgual[c3]
1 5
25 z_menorIgual[c0]
1 5
26 z_menorIgual[c2]
1 5
No. Column name Activity Lower bound Upper bound
------ ------------ ------------- ------------- -------------
1 x[c2,v0] * 0 0 1
2 x[c2,v1] * 1 0 1
3 x[c2,v2] * 0 0 1
4 x[c0,v0] * 1 0 1
5 x[c0,v1] * 0 0 1
6 x[c0,v2] * 0 0 1
7 x[c1,v0] * 0 0 1
8 x[c1,v1] * 0 0 1
9 x[c1,v2] * 1 0 1
1 x[c1,v0] * 1 0 1
2 x[c1,v1] * 0 0 1
3 x[c1,v2] * 0 0 1
4 x[c1,v3] * 0 0 1
5 x[c1,v4] * 0 0 1
6 x[c4,v0] * 0 0 1
7 x[c4,v1] * 0 0 1
8 x[c4,v2] * 1 0 1
9 x[c4,v3] * 0 0 1
10 x[c4,v4] * 0 0 1
11 x[c3,v0] * 0 0 1
12 x[c3,v1] * 0 0 1
13 x[c3,v2] * 0 0 1
14 x[c3,v3] * 0 0 1
15 x[c3,v4] * 1 0 1
16 x[c0,v0] * 0 0 1
17 x[c0,v1] * 1 0 1
18 x[c0,v2] * 0 0 1
19 x[c0,v3] * 0 0 1
20 x[c0,v4] * 0 0 1
21 x[c2,v0] * 0 0 1
22 x[c2,v1] * 0 0 1
23 x[c2,v2] * 0 0 1
24 x[c2,v3] * 1 0 1
25 x[c2,v4] * 0 0 1
End of output
SORTEO,test
CANTIDAD_VIVIENDAS,5
-,v1,v2,v3,v4,v5
M,1,2,3,4,5
S,1,1,1,2,3
A,1,2,3,2,3
U,2,3,3,3,1
O,1,4,5,2,3
SORTEO,test
CANTIDAD_VIVIENDAS,7
-,v1,v2,v3,v4,v5,v6,v7
M,1,2,3,4,5,6,7
S,1,1,1,2,3,3,4
A,1,2,3,2,3,4,5
U,2,3,3,3,1,1,1
O,1,4,5,2,3,2,2
L,7,6,5,4,3,2,1
K,1,1,1,1,1,1,2
SORTEO,test
CANTIDAD_VIVIENDAS,12
-,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12
M,1,2,3,4,5,6,7,8,9,10,11,12
S,1,1,1,2,3,3,4,2,2,5,1,2
A,1,2,3,2,3,4,5,2,6,7,8,9
U,2,3,3,3,1,1,1,6,5,4,3,2
O,1,4,5,2,3,2,2,6,7,9,8,10
L,7,6,5,4,3,2,1,7,7,7,6,7
K,1,1,1,1,1,1,2,1,1,1,1,1
Q,2,1,2,2,2,2,2,2,2,2,2,2
W,9,8,7,6,5,4,3,2,1,9,8,7
E,10,10,10,9,8,7,6,5,4,3,2,1
R,1,2,3,4,5,6,7,8,9,10,11,12
T,1,1,1,1,1,1,1,1,1,1,1,1
/****************************************************************************
** Meta object code from reading C++ file 'progressbar.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.7.1)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../progressbar.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'progressbar.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.7.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
struct qt_meta_stringdata_ProgressBar_t {
QByteArrayData data[1];
char stringdata0[12];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_ProgressBar_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_ProgressBar_t qt_meta_stringdata_ProgressBar = {
{
QT_MOC_LITERAL(0, 0, 11) // "ProgressBar"
},
"ProgressBar"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_ProgressBar[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
0 // eod
};
void ProgressBar::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
Q_UNUSED(_o);
Q_UNUSED(_id);
Q_UNUSED(_c);
Q_UNUSED(_a);
}
const QMetaObject ProgressBar::staticMetaObject = {
{ &QDialog::staticMetaObject, qt_meta_stringdata_ProgressBar.data,
qt_meta_data_ProgressBar, qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};
const QMetaObject *ProgressBar::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *ProgressBar::qt_metacast(const char *_clname)
{
if (!_clname) return Q_NULLPTR;
if (!strcmp(_clname, qt_meta_stringdata_ProgressBar.stringdata0))
return static_cast<void*>(const_cast< ProgressBar*>(this));
return QDialog::qt_metacast(_clname);
}
int ProgressBar::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QDialog::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}
QT_END_MOC_NAMESPACE
#include "glpk.h"
#include <QFile>
#include <QProgressDialog>
#include <QTimeLine>
#include <QTextStream>
#include <QProcess>
#include <QDir>
......@@ -7,13 +9,14 @@
#include <QMessageBox>
#include <QDebug>
#include "mainwindow.h"
#include "progressbar.h"
GLPK::GLPK(Simulation* & simulacion)
{
this->simulacion = simulacion;
}
void GLPK::ejecutar(QProcess* process){
bool GLPK::ejecutar(QProcess* process, QWidget* parent){
QString MTAV_nombre = "MTAV_pref";
QString MTAV_empate_nombre = "MTAV_pref_empate";
......@@ -39,11 +42,43 @@ void GLPK::ejecutar(QProcess* process){
QString command = "cmd.exe /C " + arguments.at(0) + " & " + arguments.at(1) + "\"";
QProgressDialog progress(parent);
progress.setLabelText("Calculando mejor escenario.. .");
progress.setRange(0, 100);
progress.setModal(true);
for (int row = 0; row < 5; ++row) {
progress.setValue(row);
qApp->processEvents();
if (progress.wasCanceled()) {
return true;
}
int ms = 300 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(700)));
Sleep(ms);
}
process->start(command);
process->waitForStarted();
process->waitForFinished(60001);
// process->waitForFinished(60001);
for (int t = 0; t < 12; ++t) {
int add = rand() / static_cast <float> (RAND_MAX/(40-progress.value()));
int new_val = (progress.value() + add);
progress.setValue(new_val);
qApp->processEvents();
if (progress.wasCanceled()) {
return true;
}
if (process->state() == QProcess::ProcessState::NotRunning) {
break;
}
Sleep(5001);
}
progress.setValue(50);
qApp->processEvents();
process->waitForFinished(100);
QString output = process->readAllStandardOutput();
QFile process_log(QCoreApplication::applicationDirPath() + "/" + GLPK_LOG_PATH + MTAV_nombre + ".log");
......@@ -52,7 +87,6 @@ void GLPK::ejecutar(QProcess* process){
proccess_output << output;
process_log.close();
if (output.contains("FOUND"))
qInfo() << "GLPK MTAV Status: FOUND";
else
......@@ -77,16 +111,39 @@ void GLPK::ejecutar(QProcess* process){
arguments << "\" cd \"" + QCoreApplication::applicationDirPath() + "/\"";
arguments << comandoEmpate;
for (int t = 0; t < 6; ++t) {
progress.setValue(progress.value()+t*2);
qApp->processEvents();
if (progress.wasCanceled()) {
return true;
}
int ms = 300 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(200)));
Sleep(ms);
}
process->start("cmd.exe /c " + arguments.at(0) + " & " + arguments.at(1) + "\"");
process->waitForStarted();
process->waitForFinished();
for (int t = 0; t < 6; ++t) {
int add = rand() / static_cast <float> (RAND_MAX/(90-progress.value()));
progress.setValue(progress.value() + add);
qApp->processEvents();
if (progress.wasCanceled()) {
return true;
}
if (process->state() == QProcess::ProcessState::NotRunning) {
break;
}
Sleep(4000);
}
progress.setValue(98);
qApp->processEvents();
process->waitForFinished(100);
output = process->readAllStandardOutput();
if (output.contains("FOUND")) {
// ventana_expectativa();
Sleep(1000);
qInfo() << "GLPK MTAV_Empate Status: FOUND";
}
else {
......@@ -94,6 +151,10 @@ void GLPK::ejecutar(QProcess* process){
}
procesarSolucionEmpate(MTAV_empate_nombre);
progress.setValue(100);
qApp->processEvents();
return false;
}
QString GLPK::generarEntradaGLPK_MTAV(){
......@@ -122,16 +183,14 @@ QString GLPK::generarEntradaGLPK_MTAV(){
glpkEntrada += "set V :=" + strV + ";\n\n";
glpkEntrada += "param p :" + strV + " :=\n";
for (int k=0; k< simulacion->getCantidad(); k++){
for (int k=0; k < simulacion->getCantidad(); k++){
int i = cRandom.at(k);
QStringList preferenciaFila = simulacion->getPreferencias().value(i);
QString filaStr = "";
for (int j= 1; j < simulacion->getCantidad() + 1; j++){
// filaStr += QString::number(mapeoViviendaANumero[preferenciaFila.at(j)]) + " ";
filaStr += preferenciaFila.at(j) + " ";
}
filaStr = filaStr.remove(filaStr.length()-1, 1);
......@@ -146,8 +205,23 @@ QString GLPK::generarEntradaGLPK_MTAV(){
QString GLPK::generarEntradaGLPK_Empate(QString archivoSolMTAV, QString glpkMTAV){
QString error;
QFile file(archivoSolMTAV);
file.open(QIODevice::ReadOnly | QIODevice::Text);
for (int k=0; k < 5; k++){
if (file.exists())
break;
else
Sleep(500);
}
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
error = file.errorString();
QMessageBox msgBox;
msgBox.setText(error);
msgBox.exec();
}
QTextStream in(&file);
......
......@@ -5,6 +5,7 @@
#include <QStringList>
#include "simulation.h"
#include <QProcess>
#include <QProgressDialog>
#define GLPK_TIMEOUT_SECS "60"
#define GLPK_DATA_PATH "GLPK/Datos/"
......@@ -27,7 +28,7 @@ private:
public:
GLPK(Simulation* & simulacion);
void ejecutar(QProcess* p);
bool ejecutar(QProcess* p, QWidget* parent);
};
#endif // GLPK_H
......@@ -35,7 +35,7 @@ MainWindow::MainWindow(QWidget *parent) :
QLabel* statusVersionMTAV = new QLabel();
statusVersionMTAV->setAlignment( Qt::AlignRight );
statusVersionMTAV->setText(QString("MTAV Versión 1.0"));
statusVersionMTAV->setText(QString("MTAV Versión 3.0"));
this->ui->statusBar->setContentsMargins(margins);
this->ui->statusBar->addPermanentWidget(statusText,1 );
this->ui->statusBar->addPermanentWidget(statusVersionMTAV,1 );
......
......@@ -7,10 +7,12 @@ INPUT(
./debug\simulationresultwidget.o
./debug\householdseditorwidget.o
./debug\configurationwidget.o
./debug\progressbar.o
./debug\qrc_resources.o
./debug\moc_mainwindow.o
./debug\moc_dataeditorwidget.o
./debug\moc_simulationresultwidget.o
./debug\moc_householdseditorwidget.o
./debug\moc_configurationwidget.o
./debug\moc_progressbar.o
);
......@@ -7,10 +7,12 @@ INPUT(
./release\simulationresultwidget.o
./release\householdseditorwidget.o
./release\configurationwidget.o
./release\progressbar.o
./release\qrc_resources.o
./release\moc_mainwindow.o
./release\moc_dataeditorwidget.o
./release\moc_simulationresultwidget.o
./release\moc_householdseditorwidget.o
./release\moc_configurationwidget.o
./release\moc_progressbar.o
);
#include "progressbar.h"
#include "ui_progressbar.h"
ProgressBar::ProgressBar(QWidget *parent) :
QDialog(parent),
ui(new Ui::ProgressBar)
{
ui->setupUi(this);
}
void ProgressBar::setRange(int b, int t)
{
ui->progressBar->setRange(b,t);
}
void ProgressBar::setValue(int v)
{
ui->progressBar->setValue(v);
}
ProgressBar::~ProgressBar()
{
delete ui;
}
#ifndef PROGRESSBAR_H
#define PROGRESSBAR_H
#include <QDialog>
namespace Ui {
class ProgressBar;
}
class ProgressBar : public QDialog
{
Q_OBJECT
public:
explicit ProgressBar(QWidget *parent = 0);
void setRange(int bottom, int top);
void setValue(int value);
~ProgressBar();
private:
Ui::ProgressBar *ui;
};
#endif // PROGRESSBAR_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProgressBar</class>
<widget class="QDialog" name="ProgressBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>360</width>
<height>97</height>
</rect>
</property>
<property name="windowTitle">
<string>Espere</string>
</property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>250</x>
<y>60</y>
<width>93</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>Cancelar</string>
</property>
</widget>
<widget class="QProgressBar" name="progressBar">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>321</width>
<height>23</height>
</rect>
</property>
<property name="value">
<number>24</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>60</y>
<width>191</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>Calculando mejor escenario. . .</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
......@@ -37,6 +37,7 @@ void Simulation::setPreferencias(QHash<int, QStringList> preferencias)
this->preferencias = preferencias;
// Genero mapeo de viviendas con numeros, para usar en GLPK
// key es la pref, value es la vivienda
this->preferenciasMapeoNumero.clear();
......@@ -175,7 +176,7 @@ QString Simulation::generarReporte(QString ruta)
printer.setPageMargins(12,5,12,12, QPrinter::Millimeter);
printer.setOutputFileName(ruta);
QSizeF size = printer.paperSize(QPrinter::Point);
QSizeF size;// = printer.paperSize(QPrinter::Point);
textDocument.setPageSize(size);
QTextCharFormat smallTextFormat = QTextCharFormat();
......@@ -239,13 +240,14 @@ QString Simulation::generarReporte(QString ruta)
tableFormat.setCellPadding(5);
tableFormat.setColumnWidthConstraints(columnsSize);
QTextTable *textTable = cursor.insertTable(rows + 1, 2, tableFormat);
QTextTable *textTable = cursor.insertTable(rows + 1, 3, tableFormat);
QTextCharFormat formatCellTitle;
formatCellTitle.setBackground(QColor("#daf7dc"));
textTable->cellAt( 0, 0).setFormat(formatCellTitle);
textTable->cellAt( 0, 1).setFormat(formatCellTitle);
textTable->cellAt( 0, 2).setFormat(formatCellTitle);
QTextCursor textCursor = textTable->cellAt( 0, 0).firstCursorPosition();
QTextBlockFormat blockFormat = textCursor.blockFormat();
......@@ -260,16 +262,34 @@ QString Simulation::generarReporte(QString ruta)
textCursor.setBlockFormat(blockFormat);
textCursor.insertText("Asignación",formatCellTitle);
textCursor = textTable->cellAt( 0, 2).firstCursorPosition();
blockFormat = textCursor.blockFormat();
blockFormat.setAlignment(Qt::AlignHCenter);
textCursor.setBlockFormat(blockFormat);
textCursor.insertText("Preferencia",formatCellTitle);
for( int i = 0; i < rows; i++ ) {
QString familia = this->preferencias[i].at(0);
textTable->cellAt( i+1, 0).firstCursorPosition().insertText(familia);
QString vivienda = this->getViviendasMapeo()[this->asignaciones[i].toInt()];
textTable->cellAt( i+1, 1).firstCursorPosition().insertText(vivienda);
QString pref = this->preferencias[i].at(asignaciones[i].toInt() + 1);
textTable->cellAt( i+1, 2).firstCursorPosition().insertText(pref);
}
cursor.movePosition(QTextCursor::End);
// cursor.insertBlock();
// cursor.insertBlock();
// cursor.insertText("Análisis del sorteo -> " + this->nombre, TitleTextFormat);
// cursor.insertBlock();
// cursor.insertBlock();
// QTextTable *textTable = cursor.insertTable(rows + 1, 3, tableFormat);
textDocument.print(&printer);
return fileName;
......@@ -291,90 +311,98 @@ void Simulation::interpretarBloques(int* prefs, int maxima_pref, int fila) {
}
}
this->setPreferencias(preferencias);
this->preferencias.clear();
this->preferencias = preferencias;
}
QString Simulation::validar()
{
QString error = QString("");
QString errores = QString("");
if (this->nombre.isEmpty())
error = "Nombre de sorteo vacio";
else {
error = "";
// Chequeo de filas
// Verifico
// - nombre de familia no vacio y no repetido
// - que cada fila tenga todas las preferencias elegidas y que no se repitan
QStringList familias;
errores = "* Nombre de sorteo vacío. \n";
for (int i=0; i < this->preferencias.count(); i++){
QString familiaNombre = this->preferencias[i].at(0);
if (familiaNombre.isEmpty()) {
error = "El nombre de la familia no puede estar vacio";
return error;
}
// Verifico
// - nombre de familia no vacio y no repetido
// - que cada fila tenga las preferencias
QStringList familias;
if (familias.contains(familiaNombre)){
error = "La familia: " + familiaNombre + " aparece mas de una vez";
return error;
}
for (int i=0; i < this->preferencias.count(); i++){
if (preferencias[i].count() - 1 < this->cantidad){
error = "Falta asignar viviendas a familia: " + familiaNombre;
return error;
}
QString familiaNombre = this->preferencias[i].at(0);
if (familiaNombre.isEmpty()) {
errores += QString("* La familia en la fila %1 debe tener un nombre asociado. \n").arg(i+1);
}
else if (familias.contains(familiaNombre)){
errores += "* La familia: " + familiaNombre + " aparece mas de una vez. \n";
}
else {
familias.append(familiaNombre);
}
}
int preferenciasSeleccionadas[this->cantidad] = { 0 };
int maxima_pref = 0;
if (errores == "") {
int cant_err = 0;
for (int j=1; j < this->cantidad + 1; j++){
QString viviendaPref = preferencias[i].at(j);
for (int i=0; i < this->preferencias.count(); i++){
if (cant_err < 12) {
QString familiaNombre = this->preferencias[i].at(0);
if (viviendaPref.isEmpty()) {
error = "La familia " + preferencias[i].at(0) + " no tiene preferencia elegida para la vivienda: " + viviendasMapeo[j-1];
return error;
}
if (preferencias[i].count() - 1 < this->cantidad){
errores += "* Falta asignar viviendas a la familia: " + familiaNombre + ". \n";
cant_err++;
}
bool esNumero = false;
int preferencia = viviendaPref.toInt(&esNumero);
int preferenciasSeleccionadas[this->cantidad] = { 0 };
int maxima_pref = 0;
if ((!esNumero) || (preferencia < 1)){
error = "La familia " + preferencias[i].at(0) + " tiene entre sus preferencias la preferencia: " + viviendaPref + ", la cual no es correcta. (Debe ser un número entre 1 y " + QString::number(this->cantidad) + ")";
return error;
}
int j=1;
while ((cant_err < 12) && (j < this->cantidad + 1)) {
QString viviendaPref = preferencias[i].at(j);
if (!(preferenciasMapeoNumero.contains(viviendaPref))){
error =