Skip to content
Browse files

misc.pl changed to beter scale SimOutcome and sub_problem.pl

  • Loading branch information...
1 parent ade13c6 commit e148f6f63f63fa8ebd03849860061fb4986479cb Andrea Borghesi committed Oct 4, 2012
Showing with 94 additions and 38 deletions.
  1. +3 −3 misc.pl
  2. +4 −5 nogoods.pl
  3. +30 −30 risultati_sintetici.pl
  4. +57 −0 sub_problem.pl
View
6 misc.pl
@@ -11,13 +11,13 @@
sum(IncentiviInst,SumIncIns),
sum(Outcomes,SumOutcome),
AvgIncIns is SumIncIns/NumRes,
- %occorre tenere conto del fattore di scala (qui *100 è solo a fini di test)
- AvgOutcome is SumOutcome/(NumRes*100).
+ %occorre tenere conto del fattore di scala
+ AvgOutcome is SumOutcome/(NumRes*100)+400.
%predicato per testing
avg_out(IncPer):-
open('ris.txt',write,outfile),
- [risultati_sintetici],
+ [simResValori],
findall(O,result(_,IncPer,_,_,O),Outcomes),
length(Outcomes,Len), sum(Outcomes,SumOutcome),
AvgOut is SumOutcome/Len,
View
9 nogoods.pl
@@ -1,7 +1,6 @@
nogoods("Impianti fotovoltaici",0).
nogoods("Impianti fotovoltaici",6).
-nogoods("Impianti fotovoltaici",6).
-nogoods("Impianti fotovoltaici",7).
-nogoods("Impianti fotovoltaici",7).
-nogoods("Impianti fotovoltaici",7).
-nogoods("Impianti fotovoltaici",7).
+nogoods("Impianti fotovoltaici",12).
+nogoods("Impianti fotovoltaici",18).
+nogoods("Impianti fotovoltaici",23).
+nogoods("Impianti fotovoltaici",28).
View
60 risultati_sintetici.pl
@@ -1,31 +1,31 @@
%incentivi installazione, percentuale incentivi, incentivi produzione, spesa totale (euro), energia prodotta (kW)
-result(9452250, 6, 141038445, 150490695, 35308).
-result(9442914, 6, 146137711, 155580625, 35269).
-result(6848502, 6, 98423911, 105272413, 25572).
-result(8278548, 6, 124035192, 132313740, 30903).
-result(8142364, 6, 123142212, 131284576, 30428).
-result(7571734, 6, 109102787, 116674521, 28338).
-result(8542582, 6, 126780284, 135322866, 31930).
-result(7532668, 6, 112381830, 119914498, 28130).
-result(8941952, 6, 136112207, 145054159, 33367).
-result(8864584, 6, 129975476, 138840060, 33149).
-result(7359766, 6, 111150675, 118510441, 27520).
-result(7803648, 6, 118615020, 126418668, 29117).
-result(8207180, 6, 123220652, 131427832, 30625).
-result(8743602, 6, 128346431, 137090033, 32689).
-result(8666636, 6, 131392436, 140059072, 32330).
-result(10127886, 6, 154188252, 164316138, 37819).
-result(8481182, 6, 127729973, 136211155, 31671).
-result(8188624, 6, 120533988, 128722612, 30591).
-result(8423432, 6, 128743143, 137166575, 31517).
-result(9631746, 6, 143730714, 153362460, 35997).
-result(7480766, 6, 111059117, 118539883, 27942).
-result(8302304, 6, 124081657, 132383961, 31027).
-result(9534258, 6, 143585997, 153120255, 35644).
-result(9098894, 6, 138608792, 147707686, 34052).
-result(9283070, 6, 137397285, 146680355, 34728).
-result(9691054, 6, 147065344, 156756398, 36237).
-result(8324344, 6, 125766719, 134091063, 31105).
-result(8016302, 6, 120252272, 128268574, 29920).
-result(7928756, 6, 119071601, 127000357, 29589).
-result(8182352, 6, 121294136, 129476488, 30557).
+result(28835296, 23, 113204042, 142039338, 28065).
+result(34663914, 23, 140536196, 175200110, 33795).
+result(37958508, 23, 151196633, 189155141, 36995).
+result(34899722, 23, 136576878, 171476600, 34042).
+result(38185584, 23, 147345788, 185531372, 37226).
+result(33671304, 23, 132985673, 166656977, 32797).
+result(32357618, 23, 126450688, 158808306, 31537).
+result(39132700, 23, 152824954, 191957654, 38117).
+result(33082884, 23, 133930111, 167012995, 32242).
+result(38447432, 23, 150433734, 188881166, 37475).
+result(30291884, 23, 117759778, 148051662, 29548).
+result(34789504, 23, 135363232, 170152736, 33973).
+result(38454214, 23, 149487141, 187941355, 37463).
+result(29942322, 23, 120177057, 150119379, 29173).
+result(32476120, 23, 128554650, 161030770, 31675).
+result(31640092, 23, 125382617, 157022709, 30825).
+result(27793332, 23, 108448243, 136241575, 27088).
+result(33493296, 23, 130441228, 163934524, 32634).
+result(32974776, 23, 128112887, 161087663, 32140).
+result(31312580, 23, 122080139, 153392719, 30525).
+result(33856988, 23, 137633372, 171490360, 32965).
+result(41198592, 23, 162996655, 204195247, 40155).
+result(33548452, 23, 131908397, 165456849, 32674).
+result(32478656, 23, 128922229, 161400885, 31657).
+result(34816772, 23, 142110645, 176927417, 33920).
+result(30781374, 23, 123036091, 153817465, 30033).
+result(34603240, 23, 137296086, 171899326, 33704).
+result(29113732, 23, 113192604, 142306336, 28385).
+result(35187388, 23, 137984189, 173171577, 34293).
+result(39183226, 23, 153792949, 192976175, 38189).
View
57 sub_problem.pl
@@ -21,6 +21,61 @@
%relazione tra pecentuale incentivi e l'outcome simulato: rilassamento ricavato tramite regressione lineare
%OutcomePV = m*IncPer+q, m=2645MW q=405MW
+ sub:( FunzInc $= (DeltaInc)*2645*0.01 ),
+
+ sub:(DeltaOut $>= FunzInc ),
+
+ sub:(Out $= DeltaOut-FunzInc ),
+ sub:eplex_solve(Out),
+
+ %open('ris.txt',write,out),
+
+ writeln_tee("------Sub Problem-------"),
+ write_tee("Differenza tra outcome atteso e simulato: "), writeln_tee(DeltaOut),
+ sub:eplex_var_get(Out,typed_solution,OutVal),
+ write_tee("Out value: "), writeln_tee(OutVal),
+ sub:eplex_var_get(FunzInc,typed_solution,FunzIncVal),
+ sub:eplex_var_get(DeltaInc,typed_solution,DeltaIncVal),
+ write_tee("FunzInc value: "), writeln_tee(FunzIncVal),
+ NewIncPerc is IncPerc+DeltaIncVal,
+ %se il nuovo valore di incentivo coincide col vecchio aumento comunque di 1 ( se l'outcome richiesto
+ %fosse stato ottenuto sub_probl non sarebbe stato chiamato )
+ (NewIncPerc == IncPerc
+ -> NNewIncPerc is NewIncPerc+1
+ ; NNewIncPerc = NewIncPerc
+ ),
+ sub:eplex_var_get(NNewIncPerc,typed_solution,IPVal),
+ write_tee("IncPer value: "), writeln_tee(IPVal),
+ write_tee("Delta IncPer value: "), writeln_tee(DeltaIncVal),
+
+ %close(outfile),
+
+
+ %inserisci nuovo vincolo su percentuale incentivi in nogood
+ open('nogoods.pl',update,nogoodfile),
+ seek(nogoodfile,end_of_file),
+ write(nogoodfile,"nogoods(\"Impianti fotovoltaici\","), %in realtà il tipo di nogood deve essere passato come parametro a sub_probl
+ write(nogoodfile,IPVal), write(nogoodfile,").\n"),
+
+ close(nogoodfile).
+
+sub_problemOld(IncPerc,OutcomeAtteso,SimOutcome):-
+
+ DeltaOut is OutcomeAtteso-SimOutcome,
+
+ %l'uscita attesa insegue la differenza tra l'outcome atteso e quello simulato
+ sub:eplex_solver_setup(min(DeltaOut-FunzInc)),
+ sub:eplex_set(dual_solution,yes),
+
+ %creazione variabili
+ sub:(DeltaInc $:: 0..40),
+ sub:integers(DeltaInc),
+
+ %vincoli derivanti dal master
+ %sub:(IncPer $>= IncPerc ),
+
+ %relazione tra pecentuale incentivi e l'outcome simulato: rilassamento ricavato tramite regressione lineare
+ %OutcomePV = m*IncPer+q, m=2645MW q=405MW
%con questa formula il valore minimo in MW è ovviamente 405: maggiore dei 400 richiesti con piano_ampliato(ele,2013)
%per ovviare a questo problema trascuro il termine costante nei casi in cui il il valore sia minore di 405
(DeltaOut >= 405
@@ -63,3 +118,5 @@
write(nogoodfile,IPVal), write(nogoodfile,").\n"),
close(nogoodfile).
+
+

0 comments on commit e148f6f

Please sign in to comment.
Something went wrong with that request. Please try again.