private static void PrintResults(GAMSDatabase db, int instanceIx, bool enforceOrigin) { string ostr = ""; ostr += $"Instance {instanceIx + 1} {(enforceOrigin ? "with" : "w/out")} enforced origin\n"; ostr += $"Delays {GDXUtils.GetLevelsStr(db.GetVariable("v"))}\n"; ostr += $"Costs:\t{db.GetVariable("f").FirstRecord().Level}\n"; int numGoods = db.GetSet("i").NumberRecords; int numComponents = db.GetSet("k").NumberRecords; var z = db.GetVariable("z"); var xint = db.GetVariable("xint"); var x = db.GetVariable("x"); var orders = GetOrders(db.GetVariable("w")); // first good is external source (not from disassembling but instead from order) for (int i = 1; i < numGoods; i++) { for (int k = 0; k < numComponents; k++) { int whenProvided = WhenProvided(x, i, k); ostr += $"i{i + 1},k{k + 1}: Provided at {whenProvided} "; int repairStart = GetRepairStart(z, i, k); if (repairStart >= 0) { ostr += $";; repair starts at {repairStart}"; } bool internallyProvided = InternallyProvided(xint, i, k); if (!internallyProvided) { Order o = orders.First(order => order.K == k); ostr += $";; ordered at {o.T}"; } ostr += "\n"; } } Console.WriteLine(ostr); }
public static GAMSDatabase GenerateInstance(GAMSWorkspace ws, SetSizes sizes, int seed) { Utils.SetSeed(seed); var db = ws.AddDatabase(); var setNames = new[] { "i", "k", "s", "t" }; var setDescriptions = new[] { "Gueter", "Komponenten", "Schadensbilder", "Perioden" }; GDXUtils.Sets1D(db, setNames, sizes.ToArray(), setDescriptions); var ekt = Utils.RandomValuesMatrixRowAscendingDiscrete(sizes.ngoods, sizes.ncomponents, 1, 3); var eks = Utils.RandomValuesMatrixDiscrete(sizes.ngoods, sizes.ncomponents, 2, 3); var ekreal = Utils.RandomValuesMatrixDiscrete(sizes.ngoods, sizes.ncomponents, 2, 3); GDXUtils.Parameter2D(db, "ekt", "i", "k", ekt); GDXUtils.Parameter2D(db, "eks", "i", "k", eks); GDXUtils.Parameter2D(db, "ekreal", "i", "k", ekreal); GDXUtils.Parameter1D(db, "due", "i", Utils.RandomValuesDiscrete(sizes.ngoods, 0, 20), "Liefertermin/Frist"); GDXUtils.Parameter1D(db, "c", "i", Utils.RandomValues(sizes.ngoods, 0, 150), "Verspaetungskostensatz pro ZE"); GDXUtils.Parameter1D(db, "rd", "k", Utils.RandomValuesDiscrete(sizes.ncomponents, 1, 4), "Remontagedauer in ZE"); GDXUtils.Parameter1D(db, "rc", "k", Utils.RandomValuesDiscrete(sizes.ncomponents, 1, 2), "Reparaturkapazitaet in ME"); GDXUtils.Parameter1D(db, "rmc", "k", Utils.RandomValuesDiscrete(sizes.ncomponents, 4, 6), "Remontagekapazitaet in ME"); var housingCosts = new double[sizes.ncomponents, sizes.ndamagepatterns]; for (var k = 0; k < housingCosts.GetUpperBound(0); k++) { Utils.AssignRow(housingCosts, k, Utils.RandomValuesDescending(sizes.ndamagepatterns, 0.0001, 2.0)); } GDXUtils.Parameter2D(db, "hc", "k", "s", housingCosts, "Lagerkostensatz pro ZE und ME in Zustand"); GDXUtils.Parameter2D(db, "d", "k", "s", Utils.RandomValuesMatrixRowAscendingDiscrete(sizes.ncomponents, sizes.ndamagepatterns, 0, 62), "Reparaturdauern in ZE"); GDXUtils.Parameter2D(db, "bd", "k", "s", Utils.RandomValuesMatrixRowAscendingDiscrete(sizes.ncomponents, sizes.ndamagepatterns, 1, 4), "Bestelldauer in ZE"); GDXUtils.Parameter2D(db, "bc", "k", "s", Utils.RandomValuesMatrixRowAscending(sizes.ncomponents, sizes.ndamagepatterns, 0.5, 16.0), "Bestellkostensatz pro ME in Zustand"); Console.Write($"Generated instance with seed {seed} and {db.NrSymbols} symbols: "); return(db); }