#include "filtreavalcplexultime_1passe.h" #include #include #include FiltreAvalCplexUltime1Passe::FiltreAvalCplexUltime1Passe() : FiltreAval(), m_cplex( "filtreAval", CPlexModel::Minimisation, CPlexModel::Linear, #ifndef VERBOSE_CPLEX_INTERNAL true, #else false, #endif #ifndef VERBOSE_SOLUTION_STATUS true, #else false, #endif #ifdef WRITE_CPLEX_FILE true, true #else false, false #endif ) { m_type2_prod_min.resize(I()); m_type2_prod_max.resize(I()); } euros FiltreAvalCplexUltime1Passe::calcule_solution(std::vector x, bool) { //Récupération des colonnes sélectionnées for( size_t i =0 ; im_i] = CPlan::getPlan(x[i]); } // vérification : on doit avoir un plan par centrale nucléaire for (size_t i=0; i deCplex; // récupération des recharges for (powerplants2_t i=(powerplants2_t)0; iremplis_stock(reponse[s].prod_nucleaire[i], recharges[i]); } for (powerplants2_t i=(powerplants2_t)0; im_arcs.size()-1]; } } // calcul du coût moyen de la solution valeurObjectif = (euros)0 ; for (scenario_t s = (scenario_t) 0 ; s < S() ; ++s) valeurObjectif += reponse[s].costPourScenario ; valeurObjectif /= S(); return valeurObjectif; } FiltreAvalCplexUltime1Passe::~FiltreAvalCplexUltime1Passe() { } void FiltreAvalCplexUltime1Passe::setproblemdata() { // calcul préalable des bornes de production par pas de temps, pour chaque centrale for (powerplants2_t i=(powerplants2_t)0; iremplis_min_max(m_type2_prod_min[i],m_type2_prod_max[i]); /** définition des zones horizontales */ // zones horizontales = variables // 1 - production par pas de temps pour chaque scénario for (scenario_t s=(scenario_t)0; sm_arcs.size(); a++) { const CPlan::CArc & arc = m_plans[i]->m_arcs[a]; campaign_t k = arc.m_depart->m_campaign ; if (arc.m_depart->m_type == TYPE_OUTAGE) { m_cplex.addToObj( k, RMIN(i,k).v, RMAX(i,k).v, CPlexModel::Continuous, C(i,k).v ); } } } // 3 - fuel au début et à la fin de chaque arc, et après recharge for (scenario_t s=(scenario_t)0; sm_arcs.size()); m_cplex.setZoneHorizontale( string("fuel début, centrale ")+i+" scenario "+s); for (size_t a=0;am_arcs.size();a++) m_cplex.addToObj(a,0,INFINI,CPlexModel::Continuous,0); m_cplex.addZoneHorizontale( string("fuel après, centrale ")+i+" scenario "+s, m_plans[i]->m_arcs.size()); m_cplex.setZoneHorizontale( string("fuel après, centrale ")+i+" scenario "+s); for (size_t a=0;am_arcs.size();a++) m_cplex.addToObj(a,0,INFINI,CPlexModel::Continuous,0); m_cplex.addZoneHorizontale( string("fuel fin , centrale ")+i+" scenario "+s, m_plans[i]->m_arcs.size()); m_cplex.setZoneHorizontale( string("fuel fin , centrale ")+i+" scenario "+s); for (size_t a=0;am_arcs.size()-1;a++) m_cplex.addToObj(a,0,INFINI,CPlexModel::Continuous,0); m_cplex.addToObj( m_plans[i]->m_arcs.size()-1, 0, INFINI, CPlexModel::Continuous, - C(i,K_Tp1).v / S() ); } } /** contraintes */ /// A - production = demande for (scenario_t s=(scenario_t)0; sm_arcs.size() ; m_cplex.addZoneVerticale( string("fd=ff ")+s+" "+i, nb_arcs-1 ); m_cplex.setZoneVerticale( string("fd=ff ")+s+" "+i); m_cplex.setZoneHorizontale( string("fuel début, centrale ")+i+" scenario "+s); for (size_t a=1; am_arcs[a]; campaign_t k = arc.m_depart->m_campaign; switch ( arc.m_depart->m_type ) { case TYPE_OUTAGE : m_cplex.setZoneHorizontale( string("fuel début, centrale ")+i+" scenario "+s); m_cplex.addToZ(a, a, ((coeff_t)1-(coeff_t)1/Q(i,k)).v); m_cplex.setZoneHorizontale( string("recharges ")+i); m_cplex.addToZ(a, k, 1); m_cplex.setZoneHorizontale( string("fuel après, centrale ")+i+" scenario "+s); m_cplex.addToZ(a, a, -1); m_cplex.addToRHS(a, CPlexModel::Equals, (BO(i,(campaign_t)(k-1)) * ((Q(i,k)-(coeff_t)1)/Q(i,k)) - BO(i,k)).v); break; default : m_cplex.setZoneHorizontale( string("fuel début, centrale ")+i+" scenario "+s); m_cplex.addToZ(a, a, 1); m_cplex.setZoneHorizontale( string("fuel après, centrale ")+i+" scenario "+s); m_cplex.addToZ(a, a,-1); m_cplex.addToRHS(a, CPlexModel::Equals, 0); break; } } for (size_t a=0; am_arcs[a]; campaign_t k = arc.m_depart->m_campaign; if ( arc.m_depart->m_type == TYPE_OUTAGE ) { // fuel après refuel < SMAX m_cplex.addZoneVerticale( string("farm_type != TYPE_BO and arc.m_fin->m_date!=0 ) { // fuel fin > BO m_cplex.addZoneVerticale( string("ff>BO")+s+" "+i+" "+a, 1 ); m_cplex.setZoneVerticale( string("ff>BO")+s+" "+i+" "+a); m_cplex.setZoneHorizontale( string("fuel fin , centrale ")+i+" scenario "+s); m_cplex.addToZ(0, a, 1); m_cplex.addToRHS(0, CPlexModel::GreaterThan, sup(BO(i,k)).v); } if ( arc.m_depart->m_type == TYPE_BO or arc.m_depart->m_date == (week_t)0 ) { // fuel debut fixé m_cplex.addZoneVerticale( string("fuel début fixe, scenario ")+s+" centrale "+i+" arc "+a, 1 ); m_cplex.setZoneVerticale( string("fuel début fixe, scenario ")+s+" centrale "+i+" arc "+a); m_cplex.setZoneHorizontale( string("fuel début, centrale ")+i+" scenario "+s); m_cplex.addToZ(0, a, 1); m_cplex.addToRHS(0, CPlexModel::Equals, arc.m_depart->m_fuel.v); } } // fuel après - fuel fin - production = 0 m_cplex.addZoneVerticale( string("fa_-_ff_-_p_=_0_")+s+"_"+i, nb_arcs ); for (size_t a=0; am_arcs[a]; campaign_t k = arc.m_depart->m_campaign; // fuel après - fuel fin - production = 0 m_cplex.setZoneVerticale( string("fa_-_ff_-_p_=_0_")+s+"_"+i ); m_cplex.setZoneHorizontale( string("fuel après, centrale ")+i+" scenario "+s); m_cplex.addToZ(a, a, 1); m_cplex.setZoneHorizontale( string("fuel fin , centrale ")+i+" scenario "+s); m_cplex.addToZ(a, a,-1); m_cplex.setZoneHorizontale( string("production nucléaire centrale ")+i+" scenario "+s); kWh prod_max = (kWh) 0; for ( timestep_t t=week2timestep(arc.m_depart->m_date_campaign); tm_date); ++t) { m_cplex.addToZ(a,t,-1); prod_max += EMAX(i,t); } m_cplex.addToRHS(a, CPlexModel::Equals, 0); // modulation if (arc.m_depart->m_type != TYPE_BO) { m_cplex.addZoneVerticale( string("fa_m_ff_greater_pmax_m_mmax")+s+" "+i+" "+a, 1 ); m_cplex.setZoneVerticale( string("fa_m_ff_greater_pmax_m_mmax")+s+" "+i+" "+a ); m_cplex.setZoneHorizontale( string("fuel après, centrale ")+i+" scenario "+s); m_cplex.addToZ(0, a, 1); m_cplex.setZoneHorizontale( string("fuel fin , centrale ")+i+" scenario "+s); m_cplex.addToZ(0, a,-1); m_cplex.addToRHS(0, CPlexModel::GreaterThan, (prod_max-MMAX(i,k)).v); } } } } }