Exemplo n.º 1
0
        // Generate the feature vector of the given image.
        public double[] GenerateFeature(short[,] pixelData)
        {
            // Initialize the parameters of feature (data).
            MWStructArray fea_first = new MWStructArray(1, 1, new string[] { "pixels", "maxsize" });
            fea_first.SetField("pixels", new MWNumericArray(pixelData));
            fea_first.SetField("maxsize", 75);

            // Initialize the parameters of dictionary.
            MWStructArray dic_first = new MWStructArray(1, 1, new string[] { "dicsize", "patchsize", "samplenum", "dic" });
            dic_first.SetField("dicsize", 200);
            dic_first.SetField("patchsize", 16);
            dic_first.SetField("samplenum", 100);
            MWArray array = new MWNumericArray(this.dict_dimension[0], this.dict_dimension[1], MatrixUtil.FlattenMatrix(this.dic, this.dict_dimension[0], this.dict_dimension[1]));
            dic_first.SetField("dic", array);

            // Orthogonal matching pursuit encoder
            Stopwatch ompTimer = Stopwatch.StartNew();

            MWArray rgbdfea = ompNormal.extract_feature_normal(fea_first, dic_first);

            ompTimer.Stop();

            Array feature = rgbdfea.ToArray();
            Console.WriteLine("Feature Extraction Time: {0} ms", ompTimer.ElapsedMilliseconds);

            double[] feature_vector = new double[feature.Length];
            for (int i = 0; i < feature.Length; i++)
                feature_vector[i] = System.Convert.ToDouble(feature.GetValue(i, 0));

            return feature_vector;
        }
Exemplo n.º 2
0
        //封装储热数据
        public MWStructArray[] saveH_pack()
        {
            //输入变量,结构数组
            string[] variableIn = new string[3];
            variableIn[0] = "charge";
            variableIn[1] = "H";
            variableIn[2] = "savedH";
            MWStructArray variableInStruct = new MWStructArray(1, 1, variableIn);
            variableInStruct.SetField(variableIn[0], simulatedData.Charge_HA);
            variableInStruct.SetField(variableIn[1], simulatedData.H_HA);
            variableInStruct.SetField(variableIn[2], simulatedData.SavedH_HA);

            //封装后的saveH输入变量
            string[] variableIn_pack = new string[1];
            variableIn_pack[0] = "saveh";
            MWStructArray simulatedData_saveH = new MWStructArray(1, 1, variableIn_pack);
            simulatedData_saveH.SetField(variableIn_pack[0], variableInStruct);

            //设备参数,结构数组
            string[] equipmentParameterIn = new string[3];
            equipmentParameterIn[0] = "maxH";
            equipmentParameterIn[1] = "etaIn";
            equipmentParameterIn[2] = "etaOut";
            MWStructArray equipmentParameterInStruct = new MWStructArray(1, 1, equipmentParameterIn);
            equipmentParameterInStruct.SetField(equipmentParameterIn[0], equipmentParameter.MaxH_HA);
            equipmentParameterInStruct.SetField(equipmentParameterIn[1], equipmentParameter.EtaInH_HA);
            equipmentParameterInStruct.SetField(equipmentParameterIn[2], equipmentParameter.EtaOutH_HA);

            //封装后的saveH设备参数
            string[] equipmentParameterIn_pack = new string[1];
            equipmentParameterIn_pack[0] = "saveh";
            MWStructArray equipmentParameter_saveH = new MWStructArray(1, 1, equipmentParameterIn_pack);
            equipmentParameter_saveH.SetField(equipmentParameterIn_pack[0], equipmentParameterInStruct);

            //返回数据
            MWStructArray[] structArray_Return = new MWStructArray[2];
            structArray_Return[0] = simulatedData_saveH;
            structArray_Return[1] = equipmentParameter_saveH;

            return structArray_Return;
        }
Exemplo n.º 3
0
        //封装补燃锅炉数据
        public MWStructArray[] gasBoiler_pack()
        {
            //输入变量,结构数组
            string[] variableIn = new string[2];
            variableIn[0] = "gear";
            variableIn[1] = "duration";
            MWStructArray variableInStruct = new MWStructArray(1, 1, variableIn);
            variableInStruct.SetField(variableIn[0], simulatedData.Gear_Boiler);
            variableInStruct.SetField(variableIn[1], simulatedData.Duration_Boiler);

            //封装后的gasBoiler输入变量
            string[] variableIn_pack = new string[1];
            variableIn_pack[0] = "gasboiler";
            MWStructArray simulatedData_gasBoiler = new MWStructArray(1, 1, variableIn_pack);
            simulatedData_gasBoiler.SetField(variableIn_pack[0], variableInStruct);

            //设备参数,嵌套结构数组
            //内层结构数组powerH定义 与档位对应的数组
            double[] powerH_gear_Boiler = new double[3];
            powerH_gear_Boiler[0] = equipmentParameter.PowerH_gear_Boiler_1;
            powerH_gear_Boiler[1] = equipmentParameter.PowerH_gear_Boiler_2;
            powerH_gear_Boiler[2] = equipmentParameter.PowerH_gear_Boiler_3;

            string[] equipmentParameter_PowerH = new string[1];
            equipmentParameter_PowerH[0] = "gear";
            MWStructArray powerH = new MWStructArray(1, 1, equipmentParameter_PowerH);
            powerH.SetField(equipmentParameter_PowerH[0], (MWNumericArray)powerH_gear_Boiler);

            //内层结构数组gas定义 与档位对应的数组
            double[] gas_gear_Boiler = new double[3];
            gas_gear_Boiler[0] = equipmentParameter.Gas_gear_Boiler_1;
            gas_gear_Boiler[1] = equipmentParameter.Gas_gear_Boiler_2;
            gas_gear_Boiler[2] = equipmentParameter.Gas_gear_Boiler_3;

            string[] equipmentParameter_Gas = new string[1];
            equipmentParameter_Gas[0] = "gear";
            MWStructArray gas = new MWStructArray(1, 1, equipmentParameter_Gas);
            gas.SetField(equipmentParameter_Gas[0], (MWNumericArray)gas_gear_Boiler);

            //设备参数,结构数组
            string[] equipmentParamaterIn = new string[2];
            equipmentParamaterIn[0] = "powerH";
            equipmentParamaterIn[1] = "gas";
            MWStructArray equipmentParameterInStruct = new MWStructArray(1, 1, equipmentParamaterIn);
            equipmentParameterInStruct.SetField(equipmentParamaterIn[0], powerH);
            equipmentParameterInStruct.SetField(equipmentParamaterIn[1], gas);

            //封装后的ueMachine设备参数
            string[] equipmentParameterIn_pack = new string[1];
            equipmentParameterIn_pack[0] = "gasboiler";
            MWStructArray equipmentParameter_gasboiler = new MWStructArray(1, 1, equipmentParameterIn_pack);
            equipmentParameter_gasboiler.SetField(equipmentParameterIn_pack[0], equipmentParameterInStruct);

            //返回数据
            MWStructArray[] structArray_Return = new MWStructArray[2];
            structArray_Return[0] = simulatedData_gasBoiler;
            structArray_Return[1] = equipmentParameter_gasboiler;

            return structArray_Return;
        }
Exemplo n.º 4
0
        //封装光热数据
        public MWStructArray[] pt_pack()
        {
            //输入变量,结构数组
            string[] envrmtdata = new string[1];
            envrmtdata[0] = "lout";
            MWStructArray envrmtdataStruct = new MWStructArray(1, 1, envrmtdata);
            envrmtdataStruct.SetField(envrmtdata[0], simulatedData.Envrmtdata_lout_Heat);

            string[] variableIn = new string[2];
            variableIn[0] = "envrmtdata";
            variableIn[1] = "duration";
            MWStructArray variableInStruct = new MWStructArray(1, 1, variableIn);
            variableInStruct.SetField(variableIn[0], envrmtdataStruct);
            variableInStruct.SetField(variableIn[1], simulatedData.Duration_Heat);

            //封装后的pt输入变量
            string[] variableIn_pack = new string[1];
            variableIn_pack[0] = "pt";
            MWStructArray simulatedData_pt = new MWStructArray(1, 1, variableIn_pack);
            simulatedData_pt.SetField(variableIn_pack[0], variableInStruct);

            //设备参数,结构数组
            string[] equipmentParameterIn = new string[1];
            equipmentParameterIn[0] = "power";
            MWStructArray equipmentParameterInStruct = new MWStructArray(1, 1, equipmentParameterIn);
            equipmentParameterInStruct.SetField(equipmentParameterIn[0], equipmentParameter.Power_Heat);

            //封装后的pt设备参数
            string[] equipmentParameterIn_pack = new string[1];
            equipmentParameterIn_pack[0] = "pt";
            MWStructArray equipmentParameter_pt = new MWStructArray(1, 1, equipmentParameterIn_pack);
            equipmentParameter_pt.SetField(equipmentParameterIn_pack[0], equipmentParameterInStruct);

            //返回数据
            MWStructArray[] structArray_Return = new MWStructArray[2];
            structArray_Return[0] = simulatedData_pt;
            structArray_Return[1] = equipmentParameter_pt;

            return structArray_Return;
        }
Exemplo n.º 5
0
        //封装储电数据
        public MWStructArray[] saveE_pack()
        {
            //输入变量,结构数组
            string[] variableIn = new string[4];
            variableIn[0] = "charge";
            variableIn[1] = "duration";
            variableIn[2] = "speed";
            variableIn[3] = "savedE";
            MWStructArray variableInStruct_saveE = new MWStructArray(1, 1, variableIn);
            variableInStruct_saveE.SetField(variableIn[0], simulatedData.Charge_EA);
            variableInStruct_saveE.SetField(variableIn[1], simulatedData.Duration_EA);
            variableInStruct_saveE.SetField(variableIn[2], simulatedData.Speed_EA);
            variableInStruct_saveE.SetField(variableIn[3], simulatedData.SavedE_EA);

            //封装后的saveE输入变量
            string[] variableIn_pack = new string[1];
            variableIn_pack[0] = "savee";
            MWStructArray simulatedData_saveE = new MWStructArray(1, 1, variableIn_pack);
            simulatedData_saveE.SetField(variableIn_pack[0], variableInStruct_saveE);

            //设备参数,结构数组
            string[] equipmentParameterIn = new string[5];
            equipmentParameterIn[0] = "maxE";
            equipmentParameterIn[1] = "maxInE";
            equipmentParameterIn[2] = "maxOutE";
            equipmentParameterIn[3] = "etaIn";
            equipmentParameterIn[4] = "etaOut";
            MWStructArray equipmentParameterInStruct_saveE = new MWStructArray(1, 1, equipmentParameterIn);
            equipmentParameterInStruct_saveE.SetField(equipmentParameterIn[0], equipmentParameter.MaxE_EA);
            equipmentParameterInStruct_saveE.SetField(equipmentParameterIn[1], equipmentParameter.MaxInE_EA);
            equipmentParameterInStruct_saveE.SetField(equipmentParameterIn[2], equipmentParameter.MaxOutE_EA);
            equipmentParameterInStruct_saveE.SetField(equipmentParameterIn[3], equipmentParameter.EtaInE_EA);
            equipmentParameterInStruct_saveE.SetField(equipmentParameterIn[4], equipmentParameter.EtaOutE_EA);

            //封装后的saveE设备参数
            string[] equipmentParameterIn_pack = new string[1];
            equipmentParameterIn_pack[0] = "savee";
            MWStructArray equipmentParameter_saveE = new MWStructArray(1, 1, equipmentParameterIn_pack);
            equipmentParameter_saveE.SetField(equipmentParameterIn_pack[0], equipmentParameterInStruct_saveE);

            //返回数据
            MWStructArray[] structArray_Return = new MWStructArray[2];
            structArray_Return[0] = simulatedData_saveE;
            structArray_Return[1] = equipmentParameter_saveE;

            return structArray_Return;
        }
Exemplo n.º 6
0
        //优化函数
        public ArrayList ctrlopt_Array(MWStructArray dataOutStruct)
        {
            //MWStructArray dataOutStruct = ctrlopt_Struct();

            //输出结构体的内层结构体
            MWStructArray savee = (MWStructArray)dataOutStruct.GetField("savee");
            MWStructArray saveh = (MWStructArray)dataOutStruct.GetField("saveh");
            MWStructArray pv = (MWStructArray)dataOutStruct.GetField("pv");
            MWStructArray pt = (MWStructArray)dataOutStruct.GetField("pt");
            //输出结构体的其他非嵌套成员
            MWNumericArray outsideE_dataOut = (MWNumericArray)dataOutStruct.GetField("outsideE");
            MWNumericArray outsideH_dataOut = (MWNumericArray)dataOutStruct.GetField("outsideH");

            MWStructArray uemachine_gear_dataOut = (MWStructArray)dataOutStruct.GetField("uemachine");
            MWStructArray gasboiler_gear_dataOut = (MWStructArray)dataOutStruct.GetField("gasboiler");

            string[] fieldName_savee = savee.FieldNames;
            string[] fieldName_saveh = saveh.FieldNames;
            string[] fieldName_pv = pv.FieldNames;
            string[] fieldName_pt = pt.FieldNames;

            //内层结构体Savee
            MWNumericArray charge_Savee = (MWNumericArray)savee.GetField("charge");
            MWNumericArray savedE_Savee = (MWNumericArray)savee.GetField("savedE");
            MWNumericArray deltaE_Savee = (MWNumericArray)savee.GetField("IOE");
            //内层结构体Saveh
            MWNumericArray charge_Saveh = (MWNumericArray)saveh.GetField("charge");
            MWNumericArray savedH_Saveh = (MWNumericArray)saveh.GetField("savedH");
            MWNumericArray deltaH_Saveh = (MWNumericArray)saveh.GetField("IOH");
            //内层结构体Pv
            MWNumericArray consume_Pv = (MWNumericArray)pv.GetField("consume");
            MWNumericArray save_Pv = (MWNumericArray)pv.GetField("save");
            //内层结构体Pt
            MWNumericArray consume_Pt = (MWNumericArray)pt.GetField("consume");
            MWNumericArray save_Pt = (MWNumericArray)pt.GetField("save");
            //非嵌套部分
            MWNumericArray uemachine_gear = (MWNumericArray)uemachine_gear_dataOut.GetField("gear");
            MWNumericArray gasboiler_gear = (MWNumericArray)gasboiler_gear_dataOut.GetField("gear");

            //数据类型转换
            double[,] charge_Savee_Output = (double[,])charge_Savee.ToArray(MWArrayComponent.Real);
            double[,] savedE_Savee_Output = (double[,])savedE_Savee.ToArray(MWArrayComponent.Real);
            double[,] deltaE_Savee_Output = (double[,])deltaE_Savee.ToArray(MWArrayComponent.Real);

            double[,] charge_Saveh_Output = (double[,])charge_Saveh.ToArray(MWArrayComponent.Real);
            double[,] savedH_Saveh_Output = (double[,])savedH_Saveh.ToArray(MWArrayComponent.Real);
            double[,] deltaH_Saveh_Output = (double[,])deltaH_Saveh.ToArray(MWArrayComponent.Real);

            double[,] consume_Pv_Output = (double[,])consume_Pv.ToArray(MWArrayComponent.Real);
            double[,] save_Pv_Output = (double[,])save_Pv.ToArray(MWArrayComponent.Real);

            double[,] consume_Pt_Output = (double[,])consume_Pt.ToArray(MWArrayComponent.Real);
            double[,] save_Pt_Output = (double[,])save_Pt.ToArray(MWArrayComponent.Real);

            double[,] outsideE_Output = (double[,])outsideE_dataOut.ToArray(MWArrayComponent.Real);
            double[,] outsideH_Output = (double[,])outsideH_dataOut.ToArray(MWArrayComponent.Real);
            double[,] uemachine_gear_Output = (double[,])uemachine_gear.ToArray(MWArrayComponent.Real);
            double[,] gasboiler_gear_Output = (double[,])gasboiler_gear.ToArray(MWArrayComponent.Real);

            //返回数据
            ArrayList ctrlopt_Output = new ArrayList();

            ctrlopt_Output.Add(charge_Savee_Output[0, 0]);
            ctrlopt_Output.Add(savedE_Savee_Output[0, 0]);
            ctrlopt_Output.Add(deltaE_Savee_Output[0, 0]);

            ctrlopt_Output.Add(charge_Saveh_Output[0, 0]);
            ctrlopt_Output.Add(savedH_Saveh_Output[0, 0]);
            ctrlopt_Output.Add(deltaH_Saveh_Output[0, 0]);

            ctrlopt_Output.Add(consume_Pv_Output[0, 0]);
            ctrlopt_Output.Add(save_Pv_Output[0, 0]);

            ctrlopt_Output.Add(consume_Pt_Output[0, 0]);
            ctrlopt_Output.Add(save_Pt_Output[0, 0]);

            ctrlopt_Output.Add(outsideE_Output[0, 0]);
            ctrlopt_Output.Add(outsideH_Output[0, 0]);
            ctrlopt_Output.Add(uemachine_gear_Output[0, 0]);
            ctrlopt_Output.Add(gasboiler_gear_Output[0, 0]);

            return ctrlopt_Output;
        }
Exemplo n.º 7
0
        //优化函数
        public MWStructArray ctrlopt_Struct()
        {
            //能源需求参数
            string[] need = new string[3];
            need[0] = "E";
            need[1] = "H";
            need[2] = "mode";
            MWStructArray needStruct = new MWStructArray(1, 1, need);
            needStruct.SetField(need[0], energyNeed.Electricity_Need);
            needStruct.SetField(need[1], energyNeed.Heat_Need);
            needStruct.SetField(need[2], energyNeed.Mode);

            //能源价格参数
            double price_E = 0.55;
            double price_H = 0.16;
            double price_G = 0.24;

            double mode = energyNeed.Mode;

            if (mode == 1)
            {
                price_E = simulatedData.Price_E;
                price_H = simulatedData.Price_H;
                price_G = simulatedData.Price_G;
            }
            else if (mode == 2)
            {
                price_E = 1;
                price_H = 0.28;
                price_G = 9.78;
            }
            else if (mode == 4)
            {
                price_E = 0.1384;
                price_H = 0.0398;
                price_G = 0.8218;
            }

            string[] price = new string[3];
            price[0] = "E";
            price[1] = "H";
            price[2] = "G";
            MWStructArray priceStruct = new MWStructArray(1, 1, price);
            priceStruct.SetField(price[0], price_E);
            priceStruct.SetField(price[1], price_H);
            priceStruct.SetField(price[2], price_G);

            //参数封装格式定义
            MWStructArray[] data_pv_pack = pv_pack();
            MWStructArray[] data_pt_pack = pt_pack();
            MWStructArray[] data_saveE_pack = saveE_pack();
            MWStructArray[] data_saveH_pack = saveH_pack();
            MWStructArray[] data_ueMachine = ueMachine_pack();
            MWStructArray[] data_gasBoiler = gasBoiler_pack();

            string[] variable = new string[7];
            variable[0] = "pv";
            variable[1] = "pt";
            variable[2] = "savee";
            variable[3] = "saveh";
            variable[4] = "uemachine";
            variable[5] = "gasboiler";
            variable[6] = "price";

            //输入变量提取            
            MWStructArray variableInStruct = new MWStructArray(1, 1, variable);
            variableInStruct.SetField(variable[0], data_pv_pack[0].GetField(variable[0]));
            variableInStruct.SetField(variable[1], data_pt_pack[0].GetField(variable[1]));
            variableInStruct.SetField(variable[2], data_saveE_pack[0].GetField(variable[2]));
            variableInStruct.SetField(variable[3], data_saveH_pack[0].GetField(variable[3]));
            variableInStruct.SetField(variable[4], data_ueMachine[0].GetField(variable[4]));
            variableInStruct.SetField(variable[5], data_gasBoiler[0].GetField(variable[5]));
            variableInStruct.SetField(variable[6], priceStruct);

            //设备参数提取
            MWStructArray equipmentParameterInStruct = new MWStructArray(1, 1, variable);
            equipmentParameterInStruct.SetField(variable[0], data_pv_pack[1].GetField(variable[0]));
            equipmentParameterInStruct.SetField(variable[1], data_pt_pack[1].GetField(variable[1]));
            equipmentParameterInStruct.SetField(variable[2], data_saveE_pack[1].GetField(variable[2]));
            equipmentParameterInStruct.SetField(variable[3], data_saveH_pack[1].GetField(variable[3]));
            equipmentParameterInStruct.SetField(variable[4], data_ueMachine[1].GetField(variable[4]));
            equipmentParameterInStruct.SetField(variable[5], data_gasBoiler[1].GetField(variable[5]));

            //函数调用
            object[] dataOut = uec.newctrlopt(1, needStruct, variableInStruct, equipmentParameterInStruct);
            //输出结果为嵌套结构数组,类型转换
            MWStructArray dataOutStruct = (MWStructArray)dataOut[0];
            string[] fieldName = dataOutStruct.FieldNames;

            return dataOutStruct;
        }
Exemplo n.º 8
0
        //设备效率
        public double[] etacal(MWStructArray product)
        {
            //MWStructArray product = ctrlopt_Struct();

            //能源需求参数
            string[] need = new string[3];
            need[0] = "E";
            need[1] = "H";
            need[2] = "mode";
            MWStructArray needStruct = new MWStructArray(1, 1, need);
            needStruct.SetField(need[0], energyNeed.Electricity_Need);
            needStruct.SetField(need[1], energyNeed.Heat_Need);
            needStruct.SetField(need[2], energyNeed.Mode);

            //参数封装格式定义
            MWStructArray[] data_pv_pack = pv_pack();
            MWStructArray[] data_pt_pack = pt_pack();
            MWStructArray[] data_saveE_pack = saveE_pack();
            MWStructArray[] data_saveH_pack = saveH_pack();
            MWStructArray[] data_ueMachine = ueMachine_pack();
            MWStructArray[] data_gasBoiler = gasBoiler_pack();

            string[] variable = new string[7];
            variable[0] = "pv";
            variable[1] = "pt";
            variable[2] = "savee";
            variable[3] = "saveh";
            variable[4] = "uemachine";
            variable[5] = "gasboiler";
            variable[6] = "price";

            //输入变量提取
            MWStructArray variable_uemachine = (MWStructArray)data_ueMachine[0].GetField(variable[4]);
            MWStructArray variable_gasboiler = (MWStructArray)data_gasBoiler[0].GetField(variable[5]);

            //档位重新赋值
            MWStructArray gear_uemachine_product = (MWStructArray)product.GetField("uemachine");
            string[] gear_uemachine_product_fieldNames = gear_uemachine_product.FieldNames;
            variable_uemachine.SetField(gear_uemachine_product_fieldNames[0], (MWNumericArray)gear_uemachine_product.GetField(gear_uemachine_product_fieldNames[0]));

            MWStructArray gear_gasboiler_product = (MWStructArray)product.GetField("gasboiler");
            string[] gear_gasboiler_product_fieldNames = gear_gasboiler_product.FieldNames;
            variable_gasboiler.SetField(gear_gasboiler_product_fieldNames[0], (MWNumericArray)gear_gasboiler_product.GetField(gear_gasboiler_product_fieldNames[0]));

            //内层结构数组gas定义 与档位对应的数组
            double[] gas_gear_Boiler = new double[3];
            gas_gear_Boiler[0] = equipmentParameter.Gas_gear_Boiler_1;
            gas_gear_Boiler[1] = equipmentParameter.Gas_gear_Boiler_2;
            gas_gear_Boiler[2] = equipmentParameter.Gas_gear_Boiler_3;

            string[] equipmentParameter_Gas = new string[1];
            equipmentParameter_Gas[0] = "gear";
            MWStructArray gas = new MWStructArray(1, 1, equipmentParameter_Gas);
            gas.SetField(equipmentParameter_Gas[0], (MWNumericArray)gas_gear_Boiler);

            //设备参数提取
            MWStructArray equipmentParameterInStruct = new MWStructArray(1, 1, variable);
            equipmentParameterInStruct.SetField(variable[0], data_pv_pack[1].GetField(variable[0]));
            equipmentParameterInStruct.SetField(variable[1], data_pt_pack[1].GetField(variable[1]));
            equipmentParameterInStruct.SetField(variable[2], data_saveE_pack[1].GetField(variable[2]));
            equipmentParameterInStruct.SetField(variable[3], data_saveH_pack[1].GetField(variable[3]));
            equipmentParameterInStruct.SetField(variable[4], data_ueMachine[1].GetField(variable[4]));
            equipmentParameterInStruct.SetField(variable[5], data_gasBoiler[1].GetField(variable[5]));

            //函数调用
            MWNumericArray dataOut = (MWNumericArray)uec.etacal(product, needStruct, variable_uemachine, variable_gasboiler, equipmentParameterInStruct);
            double[,] dataOutArray = (double[,])dataOut.ToArray(MWArrayComponent.Real);

            double[] etacal_Output = new double[3];
            etacal_Output[0] = dataOutArray[0, 0];
            etacal_Output[1] = dataOutArray[1, 0];
            etacal_Output[2] = dataOutArray[2, 0];

            return etacal_Output;
        }
Exemplo n.º 9
0
        //补燃锅炉
        public double[] gasBoiler(MWStructArray product)
        {
            //MWStructArray product = ctrlopt_Struct();

            MWStructArray[] data_gasBoiler_pack = gasBoiler_pack();
            MWStructArray variableInStruct = (MWStructArray)data_gasBoiler_pack[0].GetField("gasboiler");
            MWStructArray equipmentParameterInStruct = (MWStructArray)data_gasBoiler_pack[1].GetField("gasboiler");

            //档位赋值
            MWStructArray gear_gasboiler_product = (MWStructArray)product.GetField("gasboiler");
            string[] gear_gasboiler_product_fieldNames = gear_gasboiler_product.FieldNames;
            variableInStruct.SetField(gear_gasboiler_product_fieldNames[0], (MWNumericArray)gear_gasboiler_product.GetField(gear_gasboiler_product_fieldNames[0]));

            //函数调用
            object[] dataOut = uec.gasboiler(1, variableInStruct, equipmentParameterInStruct);
            MWStructArray dataOutStruct = (MWStructArray)dataOut[0];
            string[] fieldName = dataOutStruct.FieldNames;
            //将输出由MWStructArray类型转化为MWNumericArray类型
            MWStructArray prdct = (MWStructArray)dataOutStruct.GetField("prdct");
            MWStructArray consume = (MWStructArray)dataOutStruct.GetField("consume");
            string[] prdctFieldName = prdct.FieldNames;
            string[] consumeFieldName = consume.FieldNames;

            //将输出由MWNumericArray类型转化为double类型(中间需要转化为Array类型)
            MWNumericArray prdctH = (MWNumericArray)prdct.GetField("H");
            MWNumericArray consumeG = (MWNumericArray)consume.GetField("G");

            double[,] prdctH_Output = (double[,])prdctH.ToArray(MWArrayComponent.Real);
            double[,] consumeG_Output = (double[,])consumeG.ToArray(MWArrayComponent.Real);

            //返回数据
            double[] gasBoiler_Output = new double[2];
            gasBoiler_Output[0] = prdctH_Output[0, 0];
            gasBoiler_Output[1] = consumeG_Output[0, 0];

            return gasBoiler_Output;
        }
Exemplo n.º 10
0
        //泛能机
        public double[] ueMachine(MWStructArray product)
        {
            //MWStructArray product = ctrlopt_Struct();

            MWStructArray[] data_ueMachine_pack = ueMachine_pack();
            MWStructArray variableInStruct = (MWStructArray)data_ueMachine_pack[0].GetField("uemachine");
            MWStructArray equipmentParameterInStruct = (MWStructArray)data_ueMachine_pack[1].GetField("uemachine");

            MWStructArray gear_uemachine_product = (MWStructArray)product.GetField("uemachine");
            string[] gear_uemachine_product_fieldNames = gear_uemachine_product.FieldNames;
            variableInStruct.SetField(gear_uemachine_product_fieldNames[0], (MWNumericArray)gear_uemachine_product.GetField(gear_uemachine_product_fieldNames[0]));

            //uemachine函数调用
            object[] dataOut = uec.uemachine(1, variableInStruct, equipmentParameterInStruct);
            MWStructArray dataOutStruct = (MWStructArray)dataOut[0];
            //consume数组
            MWStructArray consume = (MWStructArray)dataOutStruct.GetField("consume");
            string[] fieldName_Consume = consume.FieldNames;
            MWNumericArray consumeG = (MWNumericArray)consume.GetField("G");
            double[,] consumeG_Output = (double[,])consumeG.ToArray(MWArrayComponent.Real);
            //prdct数组
            MWStructArray prdct = (MWStructArray)dataOutStruct.GetField("prdct");
            string[] fieldName_prdct = prdct.FieldNames;
            MWNumericArray prdctE = (MWNumericArray)prdct.GetField("E");
            MWNumericArray prdctH = (MWNumericArray)prdct.GetField("H");
            double[,] prdctE_Output = (double[,])prdctE.ToArray(MWArrayComponent.Real);
            double[,] prdctH_Output = (double[,])prdctH.ToArray(MWArrayComponent.Real);

            //返回数据
            double[] ueMachine_Output = new double[3];
            ueMachine_Output[0] = consumeG_Output[0, 0];
            ueMachine_Output[1] = prdctE_Output[0, 0];
            ueMachine_Output[2] = prdctH_Output[0, 0];

            return ueMachine_Output;
        }