Jannick, thank you for your new preview package !
I tried it to solve randomly generated LPs below. Now, LogToConsole=false makes annoying logs quiet, and I can reuse a sole HiGHS solver instance to solve LPs serially.
But, if I set solver to use internal point method instead of simplex method by specifying Solver="ipm" in the solver config, sometimes logs appear to console (red bold line).
And, even when LogToConsole=false, I still get these 4 lines in my console,
Normalizing all Expressions before Transforming the Model...
Normalizing 4 Constraints...
Normalizing OperatorConstraints...
Normalizing Objectives...
Especially, at the 1st solving I get these 2 lines,
Running HiGHS 1.4.2 [date: 1970-01-01, git hash: f797c1ab6]
Copyright (c) 2022 ERGO-Code under MIT licence terms
If possible, I want also to make these lines completely quiet, to use LP solvers as subloutines of my console programs.
Anyway, thank you for your kind support !
-------------------- Program.cs --------------------
using OPTANO.Modeling.Common;
using OPTANO.Modeling.Optimization;
using OPTANO.Modeling.Optimization.Enums;
using OPTANO.Modeling.Optimization.Configuration;
using OPTANO.Modeling.Optimization.Solver;
using OPTANO.Modeling.Optimization.Solver.Highs14x;
namespace demo
{
    class Program
    {
        static void Main(string[] args)
        {
            RandomLp();
        }
        static void RandomLp()
        {
            var scopeConfig = new Configuration() { NameHandling=NameHandlingStyle.Manual, CopySolutionToModel=true };
            var solverConfig = new HighsSolverConfiguration14x() { LogToConsole=false, Solver="ipm" };
            using (var scope = new ModelScope(scopeConfig))
            using (var solver = new HighsSolver14x(solverConfig))
            {
                var x = new Variable("x");
                var y = new Variable("y");
                var z = new Variable("z");
                int lpCount = 10;
                int cnCount = 4;
                int coefRange = 5;
                int constRange = 10;
                Random r = new Random();
                int rSign() => (r.Next(0, 2) % 2 == 0) ? 1 : -1;
                int rCoef() => rSign() * r.Next(1, coefRange + 1);
                int rConst() => rSign() * r.Next(1, constRange + 1);
                ObjectiveSense rObSense() => (r.Next(0, 2) % 2 == 0) ? ObjectiveSense.Minimize : ObjectiveSense.Maximize;
                void showLP(Model lp)
                {
                    Console.WriteLine("\n---------- {0} ----------", lp.Name);
                    Console.WriteLine("Variables:");
                    lp.Variables.ForEach(v => Console.WriteLine("    {0} <= {1} <= {2}", v.LowerBound, v.Name, v.UpperBound));
                    lp.Objectives.ForEach(ob => Console.WriteLine(ob.Sense == ObjectiveSense.Minimize ? "Minimize: {0}" : "Maximize {0}", ob.Expression));
                    Console.WriteLine("Constraints:");
                    lp.Constraints.ForEach(cn => Console.WriteLine("    {0}", cn.ToString()));
                }
                void showSol(Solution sol, Model lp)
                {
                    if (sol.Status == SolutionStatus.Optimal)
                    {
                        Console.WriteLine("Optimal Solution:");
                        //lp.VariableCollections.ForEach(vc => vc.SetVariableValues(sol.VariableValues));
                        lp.Variables.ForEach(v => Console.WriteLine("    {0} = {1}", v.Name, v.Value));
                    }
                    else
                    {
                        Console.WriteLine(sol.ModelStatus == ModelStatus.Infeasible ? "Infeasible Region." : sol.ModelStatus == ModelStatus.Unbounded ? "Unbounded Solution." : "");
                    }
                }
                for (int lpIdx = 0; lpIdx < lpCount; lpIdx++)
                {
                    var lp = new Model("LP_" + lpIdx.ToString());
                    for (int cnIdx = 0; cnIdx < cnCount; cnIdx++)
                    {
                        lp.AddConstraint(rCoef() * x + rCoef() * y + rCoef() * z <= rConst());
                    }
                    var ob = new Objective(rCoef() * x + rCoef() * y + rCoef() * z);
                    ob.Sense = rObSense();
                    lp.AddObjective(ob);
                    showLP(lp);
                    var sol = solver.Solve(lp);
                    showSol(sol, lp);
                    solver.ClearLastModel();
                }
            }
        }
    }
}
2023年3月24日金曜日 0:37:06 UTC+9 Jannick Lange: