Last active
December 21, 2015 05:08
-
-
Save intrueder/6254346 to your computer and use it in GitHub Desktop.
trying to use MSF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// just a wrapper around double value, indexed | |
class DV | |
{ | |
public DV(int i, double value) | |
{ | |
Id = i; | |
T = value; | |
} | |
public double Id { get; set; } | |
public double T { get; set; } | |
} | |
void Solve() | |
{ | |
var context = SolverContext.GetContext(); | |
var model = context.CreateModel(); | |
Decision a1 = new Decision(Domain.RealNonnegative, "a1"); | |
Decision tau1 = new Decision(Domain.RealNonnegative, "tau1"); | |
// inputParameters from GUI | |
a1.SetInitialValue(inputParameters[0]); | |
tau1.SetInitialValue(inputParameters[1]); | |
model.AddDecisions(a1, tau1); | |
model.AddConstraints("limits", 0 <= a1 <= 1); // not sure | |
Set tset = new Set(Domain.RealNonnegative, "tSet"); | |
Parameter t = new Parameter(Domain.RealNonnegative, "T", tset); | |
t.SetBinding(data[yi, xi].Select((o, i) => new DV(i, o)).ToArray(), "T", "Id"); | |
model.AddParameter(t); | |
model.AddGoal("goal", | |
GoalKind.Minimize, // not sure | |
Model.Sum(Model.ForEach(tset, ti => a1*Model.Exp(-ti/tau1)))); // simplified formula | |
var solution = context.Solve(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment