Skip to content
This repository has been archived by the owner on Sep 11, 2019. It is now read-only.

Commit

Permalink
Fix linearizzazione variabile logica
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxelweb committed Aug 8, 2019
1 parent 71adf7a commit 065cb32
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
19 changes: 10 additions & 9 deletions qcloud.dat
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set NotVirt := D;

param : Peso Costo :=
H 1 7.5
D 4 50.0
D 4 60.0
V1 2 12.5
V2 2 15.0
V3 2 17.5
Expand All @@ -42,23 +42,24 @@ param : Risorse Posizione Virtual :=
# Richieste effettuate all'azienda

param : Richieste :=
H 18
H 19
D 12
V1 4
V2 6
V1 2
V2 4
V3 1
V4 9
V5 2
V6 1
V4 3
V5 1
V6 2
V7 3
V8 1 ;
V8 2 ;


# Parametri costanti

param CostoWattMese := 0.054;
param MaxEccessoServer := 5;
param MinVendita := 0.75;
param MinVendita := 0.70;
param ConsumoWattMassimo := 10000;


# Attivazione dei parametri bonus
Expand Down
19 changes: 13 additions & 6 deletions qcloud.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ param Richieste{I}; # Server richiesti all'azienda
param CostoWattMese > 0; # Costo mensile Watt
param MaxEccessoServer <= 5 integer; # Massimo eccesso server
param MinVendita; # Percentuale minima di vendita
param ConsumoWattMassimo <= 10000 integer;

param N := sum{i in I} Richieste[i]; # Numero totale delle richieste

Expand All @@ -53,18 +54,14 @@ var y{J} >= 0 integer; # consumo watt nodo j
var w binary; # uso delle energie rinnovabili
var z{J} >= 0, <= MaxEccessoServer integer; # eccesso punti risorsa
var k integer; # numero degli ordini evasi
var h >= 0 integer; # watt da non pagare se con rinnovabili

# Funzione obiettivo

maximize GuadagniMensili :
(sum{i in I} sum{j in J} Costo[i]*x[i,j])
- CostoWattMese * (
sum{j in J} (
(1 - Posizione[j])*y[j]
+
(1-w)*(Posizione[j]*y[j])
)
) # Costo corrente
sum{j in J} (y[j]) - h) # Costo corrente
+ 20*(w) # Incentivo statale con uso di energie rinnovabili
- sum{j in J} z[j]; # Penale
;
Expand Down Expand Up @@ -115,6 +112,16 @@ subject to VenditaMinimaServizi_2 :
k >= N * MinVendita
;


# 7)
subject to RisparmioConEnergieRinnovabili_1 :
h <= ConsumoWattMassimo*(w);

subject to RisparmioConEnergieRinnovabili_2 :
h = sum{j in J} Virtual[j]*Posizione[j]*y[j];




# BONUS) Proporzione sul consumo elettrico dei nodi

Expand Down
8 changes: 4 additions & 4 deletions qcloud.run
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ printf "Numero di richieste (N): %i \n", N;
printf "Richieste soddisfatte (k): %i/%i (%.1f\%) \n", k, N, (k*100)/N;
printf "Uso delle energie rinnovabili (w): %s \n",
if w==1 then "Si" else "No";
printf "Watt risparmiati con energia rinnovabile (h): %i WATT\n",
h;
printf "+ Guadagni sui servizi: EUR %.2f \n",
(sum{i in I} sum{j in J} Costo[i]*x[i,j]);
printf "- Spesa energia elettrica e penali: EUR %.2f \n",
CostoWattMese * (
sum{j in J} (
(1 - Posizione[j])*y[j] + (1-w)*(Posizione[j]*y[j])
)) - 20*(w) + sum{j in J} z[j];
CostoWattMese * (sum{j in J} (y[j]) - h)
- 20*(w) + sum{j in J} z[j];
printf "= Guadagni mensili totali (f.o.): EUR %.2f \n",
GuadagniMensili;

Expand Down

0 comments on commit 065cb32

Please sign in to comment.