예제 #1
0
 /// <summary>
 /// Calls the Blender Toolkit solver with the specified input.
 /// </summary>
 public static BlenderOutput Solve(BlenderInput input)
 {
     return new BlenderOutput()
     {
         Objective = 6834,
         Shortage = 0,
         Products = new List<BlenderOutputProduct>()
         {
             new BlenderOutputProduct()
             {
                 Id = "HSD",
                 Components = new List<BlenderOutputComponent>()
                 {
                     new BlenderOutputComponent()
                     {
                         Name = "KERO",
                         OptimalVolume = 409.607
                     },
                     new BlenderOutputComponent()
                     {
                         Name = "LGO",
                         OptimalVolume = 272.489
                     },
                     new BlenderOutputComponent()
                     {
                         Name = "HGO",
                         OptimalVolume = 317.904
                     }
                 },
                 Properties = new List<BlenderOutputProperty>()
                 {
                     new BlenderOutputProperty()
                     {
                         Name = "Density",
                         OptimalValue = 0.8343
                     },
                     new BlenderOutputProperty()
                     {
                         Name = "Sulphur",
                         OptimalValue = 9
                     }
                 }
             }
         }
     };
 }
예제 #2
0
        public JSONResponseMapper<object, BlenderInput> getProducts(JSONRequestMapper<object, BlenderInput> Request)
        {
            JSONResponseMapper<object, BlenderInput> jsonResp = new JSONResponseMapper<object, BlenderInput>();

            BlenderInput obj = new BlenderInput();
            List<BlenderInputProduct> lstBInputProduct = new List<BlenderInputProduct>();
            foreach (BlenderInputProduct item in Request.data.Products)
            {
                BlenderInputProduct product = new BlenderInputProduct();
                product.Id = item.Id;
                product.MaxDemand = item.MaxDemand;
                product.Price = item.Price;
                List<BlenderInputProperty> lstBInputProperty = new List<BlenderInputProperty>();
                foreach (BlenderInputProperty p1 in item.Properties)
                {
                    BlenderInputProperty objProp = new BlenderInputProperty();
                    objProp.MinSpec = p1.MinSpec;
                    objProp.MaxSpec = p1.MaxSpec;

                    lstBInputProperty.Add(p1);
                }
                product.Properties = lstBInputProperty;
                lstBInputProduct.Add(product);
            }

            obj.Products = lstBInputProduct;

            List<BlenderInputComponent> lstBInputComponent = new List<BlenderInputComponent>();

            foreach (BlenderInputComponent item in Request.data.Components)
            {
                BlenderInputComponent component = new BlenderInputComponent();
                component.Name = item.Name;
                component.MaxAvail = item.MaxAvail;
                component.Cost = item.Cost;
                Dictionary<string, double> lstD = new Dictionary<string, double>();
                lstD = (Dictionary<string, double>)item.BlendValues;
                component.BlendValues = lstD;
                lstBInputComponent.Add(component);
            }
            obj.Components = lstBInputComponent;

            jsonResp.header = Request.header;
            jsonResp.data = Request.data;
            return jsonResp;
        }
예제 #3
0
        static void Main(string[] args)
        {
            BlenderInput input = new BlenderInput()
            {
                Products = new List<BlenderInputProduct>()
                {
                    new BlenderInputProduct()
                    {
                        Id = "HSD",
                        MaxDemand = 1000,
                        Price = 10,

                        Properties = new List<BlenderInputProperty>()
                        {
                            new BlenderInputProperty()
                            {
                                Name = "Density",
                                MinSpec = 0.8,
                                MaxSpec = 0.845
                            },
                            new BlenderInputProperty()
                            {
                                Name = "Sulphur",
                                MaxSpec = 9
                            }
                        }
                    }
                },
                Components = new List<BlenderInputComponent>()
                {
                    new BlenderInputComponent()
                    {
                        Name = "KERO",
                        MaxAvail = 500,
                        Cost = 1,
                        BlendValues = new Dictionary<string,double>() { { "Density", 0.815 }, { "Sulphur", 2 } }
                    },
                    new BlenderInputComponent()
                    {
                        Name = "LGO",
                        MaxAvail = 750,
                        Cost = 10,
                        BlendValues = new Dictionary<string,double>() { { "Density", 0.835 }, { "Sulphur", 15 } }
                    },
                    new BlenderInputComponent()
                    {
                        Name = "HGO",
                        MaxAvail = 350,
                        Cost = 0.1,
                        BlendValues = new Dictionary<string,double>() { { "Density", 0.86 }, { "Sulphur", 20 } }
                    }
                }
            };

            Console.WriteLine(input.ToString());

            Console.WriteLine("\nSolving ...\n");

            BlenderOutput output = BtkMobile.BackendInterface.Solve(input);
            Console.WriteLine(output.ToString());

            Console.ReadLine();
        }
예제 #4
0
 public BlenderInputOutput()
 {
     Input = new BlenderInput();
        Output = new BlenderOutput();
 }