对于没有经验的人来说,这可能非常令人困惑。
如何将the wikipedia article中的Set Packing问题定义为MathProg程序,稍后将在GLPK工具中运行?
单独使用Intution会让我陷入这样的境地:
var x
maximize SetPacking :
sum {s in Subsets} x
s.t. ?? //x is an integer 0 or 1
s.t. ?? //amount of x <=1
end;
但它的逻辑显然是错误的,我甚至无法完成它。
答案 0 :(得分:0)
您可以在AMPL(以及基于AMPL子集的MathProg)中制定集合打包问题,如下所示:
Members
请注意,您必须引入索引集Members[s]
,每个元素s
代表子集 package com.example.ukasz.carrom;
import android.annotation.SuppressLint;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.concurrent.TimeUnit;
public class singles_carrom extends AppCompatActivity {
public static Button start;
private static TextView timer;
MediaPlayer finish;
Counter time = new Counter(30000, 1000);
@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_singles_carrom);
start = (Button) findViewById(R.id.start);
timer = (TextView) findViewById(R.id.timer);
timer.setText("00:00:30");
finish = MediaPlayer.create(this,R.raw.gong);
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
time.start();
}
});
}
public class Counter extends CountDownTimer {
public Counter(long miliseconds, long interval) {
super(miliseconds, interval);
}
@Override
public void onTick(long millisUntilFinished) {
String hms = String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(millisUntilFinished),
TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millisUntilFinished)),
TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished)));
timer.setText(hms);
}
@Override
public void onFinish() {
finish.start();
}
}
}
的成员。这是与代数公式的唯一区别。