コード例 #1
0
ファイル: Example5.cs プロジェクト: chongtIanfei/SONNET
        public static AgriCoop LoadXml(string filePath)
        {
            using (XmlTextReader reader = new XmlTextReader(filePath))
            {
                DataContractSerializer ser = new DataContractSerializer(typeof(AgriCoop));
                AgriCoop deserialized      = (AgriCoop)ser.ReadObject(reader, true);
                reader.Close();

                return(deserialized);
            }
        }
コード例 #2
0
ファイル: Example5.cs プロジェクト: coin-or/SONNET
        public void Run(out double objValue, out string solutionString)
        {
            Producer producerA = new Producer("A", 950);
            Producer producerB = new Producer("B", 1200);
            Producer producerC = new Producer("C", 1500);
            Producer producerD = new Producer("D", 1800);

            Producer[] producers = { producerA, producerB, producerC, producerD };

            Machine senior1 = new Machine("senior1", 6);
            Machine senior2 = new Machine("senior2", 6);
            Machine senior3 = new Machine("senior3", 6);

            Machine[] machines = { senior1, senior2, senior3 };

            MachineAssignment[] machineAssignments =
            {
                new MachineAssignment(senior1, producerA, 16, 250),
                new MachineAssignment(senior1, producerB, 20, 270),
                new MachineAssignment(senior1, producerC, 40, 490),
                new MachineAssignment(senior1, producerD, 37, 460),
                new MachineAssignment(senior2, producerA, 13, 200),
                new MachineAssignment(senior2, producerB, 29, 350),
                new MachineAssignment(senior2, producerC, 38, 470),
                new MachineAssignment(senior2, producerD, 49, 630),
                new MachineAssignment(senior3, producerA, 15, 230),
                new MachineAssignment(senior3, producerB, 25, 300),
                new MachineAssignment(senior3, producerC, 42, 520),
                new MachineAssignment(senior3, producerD, 45, 550),
            };

            AgriCoop agriCoop = new AgriCoop(machines, producers, machineAssignments);

            agriCoop.Initialize();
            agriCoop.Build();
            agriCoop.Solve();

            agriCoop.SaveXml("agricoop.xml");

            AgriCoop agriCoop2 = AgriCoop.LoadXml("agricoop.xml");

            agriCoop2.Initialize();
            agriCoop2.Build();
            agriCoop2.Solve(out objValue, out solutionString);
        }